cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [1/3] git commit: Fix error with super columns in mixed 1.2-2.0 cluster
Date Wed, 02 Apr 2014 12:29:21 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 04f74a915 -> 386ed8fa6


Fix error with super columns in mixed 1.2-2.0 cluster

patch by slebresne; reviewed by iamaleksey for CASSANDRA-6966


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

Branch: refs/heads/trunk
Commit: e1a90936c709d0da1a601ef418d9b97a14ff5bb2
Parents: b42feea
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Apr 2 14:26:14 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Apr 2 14:26:14 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/cassandra/db/SuperColumns.java   | 24 ++++++++------------
 2 files changed, 11 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e1a90936/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9d27ebf..483ee0b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -39,6 +39,7 @@
  * Make sure upgradesstables keeps sstable level (CASSANDRA-6958)
  * Fix LIMT with static columns (CASSANDRA-6956)
  * Fix clash with CQL column name in thrift validation (CASSANDRA-6892)
+ * Fix error with super columns in mixed 1.2-2.0 clusters (CASSANDRA-6966)
 Merged from 1.2:
  * Add UNLOGGED, COUNTER options to BATCH documentation (CASSANDRA-6816)
  * add extra SSL cipher suites (CASSANDRA-6613)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e1a90936/src/java/org/apache/cassandra/db/SuperColumns.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SuperColumns.java b/src/java/org/apache/cassandra/db/SuperColumns.java
index 513db38..0f74587 100644
--- a/src/java/org/apache/cassandra/db/SuperColumns.java
+++ b/src/java/org/apache/cassandra/db/SuperColumns.java
@@ -260,21 +260,13 @@ public class SuperColumns
 
     public static SCFilter namesFilterToSC(CompositeType type, NamesQueryFilter filter)
     {
-        ByteBuffer scName = null;
-        SortedSet<ByteBuffer> newColumns = new TreeSet<ByteBuffer>(filter.columns.comparator());
+        SortedSet<ByteBuffer> newColumns = new TreeSet<>(type.types.get(1));
+        ByteBuffer scName = scName(filter.columns.first());
         for (ByteBuffer name : filter.columns)
         {
-            ByteBuffer newScName = scName(name);
-
-            if (scName == null)
-            {
-                scName = newScName;
-            }
-            else if (type.types.get(0).compare(scName, newScName) != 0)
-            {
-                // If we're selecting column across multiple SC, it's not something we can
translate for an old node
+            // If we're selecting column across multiple SC, it's not something we can translate
for an old node
+            if (type.types.get(0).compare(scName, scName(name)) != 0)
                 throw new RuntimeException("Cannot convert filter to old super column format.
Update all nodes to Cassandra 2.0 first.");
-            }
 
             newColumns.add(subName(name));
         }
@@ -331,10 +323,14 @@ public class SuperColumns
                     return new SCFilter(null, new SliceQueryFilter(scName(start), scName(finish),
reversed, filter.count));
                 }
             }
-            else if (filter.compositesToGroup == 0 && type.types.get(0).compare(scName(start),
scName(finish)) == 0)
+            else if (filter.compositesToGroup == -1 && type.types.get(0).compare(scName(start),
scName(finish)) == 0)
             {
                 // A slice of subcolumns
-                return new SCFilter(scName(start), filter.withUpdatedSlice(subName(start),
subName(finish)));
+                ByteBuffer newStart = subName(start);
+                ByteBuffer newFinish = subName(finish);
+                return new SCFilter(scName(start),
+                                    filter.withUpdatedSlice(newStart  == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER
: newStart,
+                                                            newFinish == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER
: newFinish));
             }
         }
         else if (!reversed)


Mime
View raw message