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 ordering of static cells
Date Mon, 18 Aug 2014 12:26:21 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 8ce346d7b -> e98a40f9e


Fix ordering of static cells

patch by slebresne; reviewed by benedict for CASSANDRA-7763


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

Branch: refs/heads/trunk
Commit: 56db00180f588cd3a5da7ae5861eefda00fbac56
Parents: 1f54010
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Mon Aug 18 14:18:02 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Mon Aug 18 14:19:04 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                              |  1 +
 .../apache/cassandra/db/composites/AbstractCType.java    | 11 +++++++++++
 .../db/composites/CompoundSparseCellNameType.java        | 11 +++++++++++
 3 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/56db0018/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f1edef4..8aafd98 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.0
+ * Fix ordering of static cells (CASSANDRA-7763)
 Merged from 2.0:
  * Fix dropping collection when it's the last regular column (CASSANDRA-7744)
  * Properly reject operations on list index with conditions (CASSANDRA-7499)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/56db0018/src/java/org/apache/cassandra/db/composites/AbstractCType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/composites/AbstractCType.java b/src/java/org/apache/cassandra/db/composites/AbstractCType.java
index e299e42..0e206c7 100644
--- a/src/java/org/apache/cassandra/db/composites/AbstractCType.java
+++ b/src/java/org/apache/cassandra/db/composites/AbstractCType.java
@@ -104,6 +104,17 @@ public abstract class AbstractCType implements CType
 
     public int compare(Composite c1, Composite c2)
     {
+        if (c1.isStatic() != c2.isStatic())
+        {
+            // Static sorts before non-static no matter what, except for empty which
+            // always sort first
+            if (c1.isEmpty())
+                return c2.isEmpty() ? 0 : -1;
+            if (c2.isEmpty())
+                return 1;
+            return c1.isStatic() ? -1 : 1;
+        }
+
         int s1 = c1.size();
         int s2 = c2.size();
         int minSize = Math.min(s1, s2);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/56db0018/src/java/org/apache/cassandra/db/composites/CompoundSparseCellNameType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/composites/CompoundSparseCellNameType.java b/src/java/org/apache/cassandra/db/composites/CompoundSparseCellNameType.java
index 29e1617..ec25e92 100644
--- a/src/java/org/apache/cassandra/db/composites/CompoundSparseCellNameType.java
+++ b/src/java/org/apache/cassandra/db/composites/CompoundSparseCellNameType.java
@@ -267,6 +267,17 @@ public class CompoundSparseCellNameType extends AbstractCompoundCellNameType
         @Override
         public int compare(Composite c1, Composite c2)
         {
+            if (c1.isStatic() != c2.isStatic())
+            {
+                // Static sorts before non-static no matter what, except for empty which
+                // always sort first
+                if (c1.isEmpty())
+                    return c2.isEmpty() ? 0 : -1;
+                if (c2.isEmpty())
+                    return 1;
+                return c1.isStatic() ? -1 : 1;
+            }
+
             int s1 = c1.size();
             int s2 = c2.size();
             int minSize = Math.min(s1, s2);


Mime
View raw message