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: Correctly compare BooleanType values other than 0 and 1
Date Wed, 12 Mar 2014 21:44:01 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 4f525b3a8 -> 94c96f38d


Correctly compare BooleanType values other than 0 and 1

Patch by Sylvain Lebresne, reviewed by Tyler Hobbs for CASSANDRA-6779


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

Branch: refs/heads/trunk
Commit: faffbf2fa344eecfad9473ae8aa2ccea17254e11
Parents: 05da045
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Mar 12 16:37:09 2014 -0500
Committer: Tyler Hobbs <tyler@datastax.com>
Committed: Wed Mar 12 16:37:09 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                               | 1 +
 src/java/org/apache/cassandra/db/marshal/BooleanType.java | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/faffbf2f/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3531737..306ef94 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,6 +5,7 @@
  * Fix static counter columns (CASSANDRA-6827)
  * Restore expiring->deleted (cell) compaction optimization (CASSANDRA-6844)
  * Fix CompactionManager.needsCleanup (CASSANDRA-6845)
+ * Correctly compare BooleanType values other than 0 and 1 (CASSANDRA-6779)
 
 2.0.6
  * Avoid race-prone second "scrub" of system keyspace (CASSANDRA-6797)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/faffbf2f/src/java/org/apache/cassandra/db/marshal/BooleanType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/BooleanType.java b/src/java/org/apache/cassandra/db/marshal/BooleanType.java
index 3a9fdfa..ca11cc2 100644
--- a/src/java/org/apache/cassandra/db/marshal/BooleanType.java
+++ b/src/java/org/apache/cassandra/db/marshal/BooleanType.java
@@ -37,7 +37,12 @@ public class BooleanType extends AbstractType<Boolean>
         if ((o2 == null) || (o2.remaining() != 1))
             return 1;
 
-        return o1.compareTo(o2);
+        // False is 0, True is anything else, makes False sort before True.
+        byte b1 = o1.get();
+        byte b2 = o2.get();
+        if (b1 == 0)
+            return b2 == 0 ? 0 : -1;
+        return b2 == 0 ? 1 : 0;
     }
 
     public ByteBuffer fromString(String source) throws MarshalException


Mime
View raw message