cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [1/10] git commit: improve validation for start key, end token ranges patch by jbellis; reviewed by dbrosius for CASSANDRA-5089
Date Thu, 27 Dec 2012 20:45:43 GMT
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.1
Commit: 8a3b29174b7b6ed921b93fe604fac95afd1d8924
Parents: 3d01ec7
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Dec 27 15:41:16 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
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);
 


Mime
View raw message