Skip to content

Commit

Permalink
Merge branch 'cassandra-1.2.0' into cassandra-1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jbellis committed Dec 27, 2012
2 parents 26a9ab1 + 4b9d927 commit fd2863d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/java/org/apache/cassandra/thrift/ThriftValidation.java
Expand Up @@ -467,9 +467,10 @@ public static void validateKeyRange(CFMetaData metadata, ByteBuffer superColumn,
if (range.start_token != null && range.end_key != null)
throw new org.apache.cassandra.exceptions.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))
Expand All @@ -480,6 +481,14 @@ public static void validateKeyRange(CFMetaData metadata, ByteBuffer superColumn,
throw new org.apache.cassandra.exceptions.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 org.apache.cassandra.exceptions.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 org.apache.cassandra.exceptions.InvalidRequestException("Start token sorts after end token");
}

validateFilterClauses(metadata, range.row_filter);

Expand Down

0 comments on commit fd2863d

Please sign in to comment.