cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [1/2] cassandra git commit: Proper implementation of LegacyBoundComparator
Date Mon, 02 Nov 2015 14:29:25 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk b1f2d14f4 -> 40d1425a1


Proper implementation of LegacyBoundComparator

patch by slebresne; reviewed by blerer for CASSANDRA-10602


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

Branch: refs/heads/trunk
Commit: cba5ef609d6d25380afcb0dff06fe325101c727c
Parents: 4beb54d
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Tue Oct 27 16:27:14 2015 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Mon Nov 2 15:28:45 2015 +0100

----------------------------------------------------------------------
 CHANGES.txt                                        |  1 +
 src/java/org/apache/cassandra/db/LegacyLayout.java | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/cba5ef60/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6d5d49b..1724f01 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0
+ * Fix implementation of LegacyLayout.LegacyBoundComparator (CASSANDRA-10602)
  * Don't use 'names query' read path for counters (CASSANDRA-10572)
  * Fix backward compatibility for counters (CASSANDRA-10470)
  * Remove memory_allocator paramter from cassandra.yaml (CASSANDRA-10581)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/cba5ef60/src/java/org/apache/cassandra/db/LegacyLayout.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/LegacyLayout.java b/src/java/org/apache/cassandra/db/LegacyLayout.java
index 6e04559..3c64443 100644
--- a/src/java/org/apache/cassandra/db/LegacyLayout.java
+++ b/src/java/org/apache/cassandra/db/LegacyLayout.java
@@ -1698,10 +1698,26 @@ public abstract class LegacyLayout
 
         public int compare(LegacyBound a, LegacyBound b)
         {
+            // In the legacy sorting, BOTTOM comes before anything else
+            if (a == LegacyBound.BOTTOM)
+                return b == LegacyBound.BOTTOM ? 0 : -1;
+            if (b == LegacyBound.BOTTOM)
+                return 1;
+
+            // Excluding BOTTOM, statics are always before anything else.
+            if (a.isStatic != b.isStatic)
+                return a.isStatic ? -1 : 1;
+
             int result = this.clusteringComparator.compare(a.bound, b.bound);
             if (result != 0)
                 return result;
 
+            // If both have equal "bound" but one is a collection tombstone and not the other,
then the other comes before as it points to the beginning of the row.
+            if (a.collectionName == null)
+                return b.collectionName == null ? 0 : 1;
+            if (b.collectionName == null)
+                return -1;
+
             return UTF8Type.instance.compare(a.collectionName.name.bytes, b.collectionName.name.bytes);
         }
     }


Mime
View raw message