Updated Branches:
  refs/heads/trunk b25b12a0a -> 9d2b26dac

make de/serializers agree to use a short length for index expression value
patch by jbellis; reviewed by David Alves for CASSANDRA-4555


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/9d2b26da
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/9d2b26da
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/9d2b26da

Branch: refs/heads/trunk
Commit: 9d2b26dac6115c2b6226c3aaebf5bae5cd381e44
Parents: b25b12a
Author: Jonathan Ellis <jbel...@apache.org>
Authored: Fri Aug 17 23:49:25 2012 -0500
Committer: Jonathan Ellis <jbel...@apache.org>
Committed: Fri Aug 17 23:49:37 2012 -0500

----------------------------------------------------------------------
 .../cassandra/cql3/statements/SelectStatement.java |    4 ++++
 .../org/apache/cassandra/db/RangeSliceCommand.java |    2 +-
 .../apache/cassandra/thrift/ThriftValidation.java  |    3 +++
 3 files changed, 8 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9d2b26da/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java 
b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index 37dd205..adc8b34 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -528,6 +528,8 @@ public class SelectStatement implements CQLStatement
                 for (Term t : restriction.eqValues)
                 {
                     ByteBuffer value = t.getByteBuffer(name.type, variables);
+                    if (value.remaining() > 0xFFFF)
+                        throw new InvalidRequestException("Index expression 
values may not be larger than 64K");
                     expressions.add(new IndexExpression(name.name.key, 
IndexOperator.EQ, value));
                 }
             }
@@ -538,6 +540,8 @@ public class SelectStatement implements CQLStatement
                     if (restriction.bound(b) != null)
                     {
                         ByteBuffer value = 
restriction.bound(b).getByteBuffer(name.type, variables);
+                        if (value.remaining() > 0xFFFF)
+                            throw new InvalidRequestException("Index 
expression values may not be larger than 64K");
                         expressions.add(new IndexExpression(name.name.key, 
restriction.getIndexOperator(b), value));
                     }
                 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9d2b26da/src/java/org/apache/cassandra/db/RangeSliceCommand.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RangeSliceCommand.java 
b/src/java/org/apache/cassandra/db/RangeSliceCommand.java
index 5511127..6632f39 100644
--- a/src/java/org/apache/cassandra/db/RangeSliceCommand.java
+++ b/src/java/org/apache/cassandra/db/RangeSliceCommand.java
@@ -233,7 +233,7 @@ class RangeSliceCommandSerializer implements 
IVersionedSerializer<RangeSliceComm
                     {
                         ByteBufferUtil.writeWithShortLength(expr.column_name, 
dos);
                         dos.writeInt(expr.op.getValue());
-                        ByteBufferUtil.writeWithLength(expr.value, dos);
+                        ByteBufferUtil.writeWithShortLength(expr.value, dos);
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9d2b26da/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 0b16eef..cf42f9e 100644
--- a/src/java/org/apache/cassandra/thrift/ThriftValidation.java
+++ b/src/java/org/apache/cassandra/thrift/ThriftValidation.java
@@ -555,6 +555,9 @@ public class ThriftValidation
                                                                 
me.getMessage()));
             }
 
+            if (expression.value.remaining() > 0xFFFF)
+                throw new InvalidRequestException("Index expression values may 
not be larger than 64K");
+
             AbstractType<?> valueValidator = 
Schema.instance.getValueValidator(metadata.ksName, metadata.cfName, 
expression.column_name);
             try
             {

Reply via email to