cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [1/3] git commit: Handle short slice start/finishes of different lengths
Date Wed, 02 Apr 2014 20:23:01 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 6fe526a56 -> cc66b6bea


Handle short slice start/finishes of different lengths

Patch by Tyler Hobbs; reviewed by Sylvain Lebresne as a follow-up for
CASSANDRA-6825


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

Branch: refs/heads/trunk
Commit: 0e98f5bd4c410d9ad453ee2000e941593a01e99f
Parents: 4f47a44
Author: Tyler Hobbs <tyler@datastax.com>
Authored: Wed Apr 2 15:17:48 2014 -0500
Committer: Tyler Hobbs <tyler@datastax.com>
Committed: Wed Apr 2 15:17:48 2014 -0500

----------------------------------------------------------------------
 src/java/org/apache/cassandra/db/marshal/CompositeType.java  | 8 +++++---
 .../org/apache/cassandra/db/marshal/CompositeTypeTest.java   | 4 ++++
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/0e98f5bd/src/java/org/apache/cassandra/db/marshal/CompositeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/CompositeType.java b/src/java/org/apache/cassandra/db/marshal/CompositeType.java
index 7f08219..32fc432 100644
--- a/src/java/org/apache/cassandra/db/marshal/CompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/CompositeType.java
@@ -278,16 +278,18 @@ public class CompositeType extends AbstractCompositeType
             // We could safely return true here, but there's a minor optimization: if the
first component is restricted
             // to a single value, we can check that the second component falls within the
min/max for that component
             // (and repeat for all components).
-            for (int i = 0; i < Math.min(Math.min(start.length, finish.length), minColumnNames.size());
i++)
+            for (int i = 0; i < minColumnNames.size(); i++)
             {
                 AbstractType<?> t = types.get(i);
+                ByteBuffer s = i < start.length ? start[i] : ByteBufferUtil.EMPTY_BYTE_BUFFER;
+                ByteBuffer f = i < finish.length ? finish[i] : ByteBufferUtil.EMPTY_BYTE_BUFFER;
 
                 // we already know the first component falls within its min/max range (otherwise
we wouldn't get here)
-                if (i > 0 && !t.intersects(minColumnNames.get(i), maxColumnNames.get(i),
start[i], finish[i]))
+                if (i > 0 && !t.intersects(minColumnNames.get(i), maxColumnNames.get(i),
s, f))
                     continue outer;
 
                 // if this component isn't equal in the start and finish, we don't need to
check any more
-                if (t.compare(start[i], finish[i]) != 0)
+                if (i >= start.length || i >= finish.length || t.compare(s, f) != 0)
                     break;
             }
             return true;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0e98f5bd/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java b/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
index 20cb5ef..df6f5e1 100644
--- a/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
+++ b/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
@@ -458,6 +458,10 @@ public class CompositeTypeTest extends SchemaLoader
         filter = new SliceQueryFilter(composite(1, 2), composite(1, 3), false, 1);
         assertFalse(comparator.intersects(columnNames(1, 0, 0), columnNames(2, 1, 0), filter));
 
+        // same case, but with missing start and end components and different lengths for
start and end
+        filter = new SliceQueryFilter(composite(1, 2), composite(1), false, 1);
+        assertFalse(comparator.intersects(columnNames(1, 0, 0), columnNames(2, 1, 0), filter));
+
 
         // same as the previous set of tests, but the second component is equal in the slice
start and end
         filter = new SliceQueryFilter(composite(1, 2, 0), composite(1, 2, 0), false, 1);


Mime
View raw message