Author: jbellis
Date: Tue Feb 16 20:39:04 2010
New Revision: 910679
URL: http://svn.apache.org/viewvc?rev=910679&view=rev
Log:
make check for range sanity partitioner-aware. patch by jbellis
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java?rev=910679&r1=910678&r2=910679&view=diff
==============================================================================
---
incubator/cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java
(original)
+++
incubator/cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java
Tue Feb 16 20:39:04 2010
@@ -24,7 +24,6 @@
import java.util.Arrays;
import org.apache.cassandra.db.KeyspaceNotDefinedException;
-import org.apache.cassandra.db.ColumnFamilyNotDefinedException;
import org.apache.cassandra.db.ColumnFamily;
import org.apache.cassandra.db.IColumn;
import org.apache.cassandra.db.marshal.AbstractType;
@@ -33,6 +32,10 @@
import static org.apache.cassandra.thrift.ThriftGlue.*;
import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.dht.IPartitioner;
+import org.apache.cassandra.dht.RandomPartitioner;
+import org.apache.cassandra.dht.Token;
+import org.apache.cassandra.service.StorageService;
public class ThriftValidation
{
@@ -316,8 +319,16 @@
if (range.start_key != null)
{
- if (range.start_key.compareTo(range.end_key) > 0 &&
!range.end_key.isEmpty())
- throw new InvalidRequestException("start key must sort before
(or equal to) finish key in your partitioner!");
+ IPartitioner p = StorageService.getPartitioner();
+ Token startToken = p.decorateKey(range.start_key).token;
+ Token endToken = p.decorateKey(range.end_key).token;
+ if (startToken.compareTo(endToken) > 0 &&
!endToken.equals(p.getMinimumToken()))
+ {
+ if (p instanceof RandomPartitioner)
+ throw new InvalidRequestException("start key's md5 sorts
after end key's md5. this is not allowed; you probably should not specify end
key at all, under RandomPartitioner");
+ else
+ throw new InvalidRequestException("start key must sort
before (or equal to) finish key in your partitioner!");
+ }
}
if (range.count <= 0)