Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9204EE7AB for ; Thu, 27 Dec 2012 20:45:45 +0000 (UTC) Received: (qmail 70876 invoked by uid 500); 27 Dec 2012 20:45:44 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 70795 invoked by uid 500); 27 Dec 2012 20:45:44 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 70384 invoked by uid 99); 27 Dec 2012 20:45:43 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Dec 2012 20:45:43 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 487E482099E; Thu, 27 Dec 2012 20:45:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jbellis@apache.org To: commits@cassandra.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [2/10] git commit: improve validation for start key, end token ranges patch by jbellis; reviewed by dbrosius for CASSANDRA-5089 Message-Id: <20121227204543.487E482099E@tyr.zones.apache.org> Date: Thu, 27 Dec 2012 20:45:43 +0000 (UTC) improve validation for start key, end token ranges patch by jbellis; reviewed by dbrosius for CASSANDRA-5089 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/8a3b2917 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/8a3b2917 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/8a3b2917 Branch: refs/heads/cassandra-1.2.0 Commit: 8a3b29174b7b6ed921b93fe604fac95afd1d8924 Parents: 3d01ec7 Author: Jonathan Ellis Authored: Thu Dec 27 15:41:16 2012 -0500 Committer: Jonathan Ellis Committed: Thu Dec 27 15:41:16 2012 -0500 ---------------------------------------------------------------------- .../apache/cassandra/thrift/ThriftValidation.java | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/8a3b2917/src/java/org/apache/cassandra/thrift/ThriftValidation.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/thrift/ThriftValidation.java b/src/java/org/apache/cassandra/thrift/ThriftValidation.java index c673a9c..de1ce56 100644 --- a/src/java/org/apache/cassandra/thrift/ThriftValidation.java +++ b/src/java/org/apache/cassandra/thrift/ThriftValidation.java @@ -493,9 +493,10 @@ public class ThriftValidation if (range.start_token != null && range.end_key != null) throw new InvalidRequestException("start token + end key is not a supported key range"); + IPartitioner p = StorageService.getPartitioner(); + if (range.start_key != null && range.end_key != null) { - IPartitioner p = StorageService.getPartitioner(); Token startToken = p.getToken(range.start_key); Token endToken = p.getToken(range.end_key); if (startToken.compareTo(endToken) > 0 && !endToken.isMinimum(p)) @@ -506,6 +507,14 @@ public class ThriftValidation throw new InvalidRequestException("start key must sort before (or equal to) finish key in your partitioner!"); } } + else if (range.end_token != null) + { + RowPosition stop = p.getTokenFactory().fromString(range.end_token).maxKeyBound(p); + if (range.start_key != null && RowPosition.forKey(range.start_key, p).compareTo(stop) > 0) + throw new InvalidRequestException("Start key's token sorts after end token"); + if (range.start_token != null && p.getTokenFactory().fromString(range.start_token).maxKeyBound(p).compareTo(stop) > 0) + throw new InvalidRequestException("Start token sorts after end token"); + } validateFilterClauses(metadata, range.row_filter);