cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Fix ColumnIdentifier comparison and use of equals for typed comparison
Date Fri, 25 Apr 2014 10:20:11 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 99de2ff6f -> 8cb81f74a


Fix ColumnIdentifier comparison and use of equals for typed comparison

patch by slebresne; reviewed by benedict for CASSANDRA-7089


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

Branch: refs/heads/cassandra-2.1
Commit: 8cb81f74a8042c2e7b19691597a3b35154bdfc4e
Parents: 99de2ff
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Fri Apr 25 12:19:10 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Fri Apr 25 12:19:10 2014 +0200

----------------------------------------------------------------------
 src/java/org/apache/cassandra/config/CFMetaData.java      |  2 +-
 src/java/org/apache/cassandra/cql3/ColumnIdentifier.java  | 10 +---------
 .../apache/cassandra/db/composites/AbstractComposite.java |  4 ++--
 .../org/apache/cassandra/db/composites/Composite.java     |  2 +-
 .../org/apache/cassandra/db/composites/Composites.java    |  2 +-
 .../org/apache/cassandra/db/filter/IDiskAtomFilter.java   |  3 ++-
 .../org/apache/cassandra/db/filter/NamesQueryFilter.java  |  5 +++--
 .../org/apache/cassandra/db/filter/SliceQueryFilter.java  |  4 ++--
 8 files changed, 13 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb81f74/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java
index 97fc241..b8c1fae 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -134,7 +134,7 @@ public final class CFMetaData
     {
         public int compare(ColumnDefinition def1, ColumnDefinition def2)
         {
-            return def1.name.compareTo(def2.name);
+            return ByteBufferUtil.compareUnsigned(def1.name.bytes, def2.name.bytes);
         }
     };
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb81f74/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java b/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
index b10f3be..0b710ba 100644
--- a/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
+++ b/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
@@ -31,7 +31,7 @@ import org.apache.cassandra.utils.memory.AbstractAllocator;
  * Represents an identifer for a CQL column definition.
  * TODO : should support light-weight mode without text representation for when not interned
  */
-public class ColumnIdentifier implements Selectable, Comparable<ColumnIdentifier>,
IMeasurableMemory
+public class ColumnIdentifier implements Selectable, IMeasurableMemory
 {
     public final ByteBuffer bytes;
     private final String text;
@@ -96,14 +96,6 @@ public class ColumnIdentifier implements Selectable, Comparable<ColumnIdentifier
              + ObjectSizes.sizeOf(text);
     }
 
-    public int compareTo(ColumnIdentifier other)
-    {
-        if (this == other)
-            return 0;
-
-        return bytes.compareTo(other.bytes);
-    }
-
     public ColumnIdentifier clone(AbstractAllocator allocator)
     {
         return new ColumnIdentifier(allocator.clone(bytes), text);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb81f74/src/java/org/apache/cassandra/db/composites/AbstractComposite.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/composites/AbstractComposite.java b/src/java/org/apache/cassandra/db/composites/AbstractComposite.java
index 9741767..bd94f88 100644
--- a/src/java/org/apache/cassandra/db/composites/AbstractComposite.java
+++ b/src/java/org/apache/cassandra/db/composites/AbstractComposite.java
@@ -97,14 +97,14 @@ public abstract class AbstractComposite implements Composite
         return size;
     }
 
-    public boolean isPrefixOf(Composite c)
+    public boolean isPrefixOf(CType type, Composite c)
     {
         if (size() > c.size() || isStatic() != c.isStatic())
             return false;
 
         for (int i = 0; i < size(); i++)
         {
-            if (!get(i).equals(c.get(i)))
+            if (type.subtype(i).compare(get(i), c.get(i)) != 0)
                 return false;
         }
         return true;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb81f74/src/java/org/apache/cassandra/db/composites/Composite.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/composites/Composite.java b/src/java/org/apache/cassandra/db/composites/Composite.java
index 9208bee..c7ed047 100644
--- a/src/java/org/apache/cassandra/db/composites/Composite.java
+++ b/src/java/org/apache/cassandra/db/composites/Composite.java
@@ -70,7 +70,7 @@ public interface Composite extends IMeasurableMemory
 
     public boolean isStatic();
 
-    public boolean isPrefixOf(Composite other);
+    public boolean isPrefixOf(CType type, Composite other);
 
     public ByteBuffer toByteBuffer();
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb81f74/src/java/org/apache/cassandra/db/composites/Composites.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/composites/Composites.java b/src/java/org/apache/cassandra/db/composites/Composites.java
index 4f05cdb..9b37d6e 100644
--- a/src/java/org/apache/cassandra/db/composites/Composites.java
+++ b/src/java/org/apache/cassandra/db/composites/Composites.java
@@ -103,7 +103,7 @@ public abstract class Composites
             return 0;
         }
 
-        public boolean isPrefixOf(Composite c)
+        public boolean isPrefixOf(CType type, Composite c)
         {
             return true;
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb81f74/src/java/org/apache/cassandra/db/filter/IDiskAtomFilter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/filter/IDiskAtomFilter.java b/src/java/org/apache/cassandra/db/filter/IDiskAtomFilter.java
index dddce00..e44a1a7 100644
--- a/src/java/org/apache/cassandra/db/filter/IDiskAtomFilter.java
+++ b/src/java/org/apache/cassandra/db/filter/IDiskAtomFilter.java
@@ -26,6 +26,7 @@ import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.columniterator.OnDiskAtomIterator;
 import org.apache.cassandra.db.composites.CellNameType;
 import org.apache.cassandra.db.composites.Composite;
+import org.apache.cassandra.db.composites.CType;
 import org.apache.cassandra.io.IVersionedSerializer;
 import org.apache.cassandra.io.sstable.SSTableReader;
 import org.apache.cassandra.io.util.DataOutputPlus;
@@ -77,7 +78,7 @@ public interface IDiskAtomFilter
     public ColumnCounter columnCounter(CellNameType comparator, long now);
 
     public IDiskAtomFilter cloneShallow();
-    public boolean maySelectPrefix(Comparator<Composite> cmp, Composite prefix);
+    public boolean maySelectPrefix(CType type, Composite prefix);
 
     public boolean shouldInclude(SSTableReader sstable);
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb81f74/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java b/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
index d6d1332..37b8d44 100644
--- a/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
+++ b/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
@@ -34,6 +34,7 @@ import org.apache.cassandra.db.columniterator.SSTableNamesIterator;
 import org.apache.cassandra.db.composites.CellName;
 import org.apache.cassandra.db.composites.CellNameType;
 import org.apache.cassandra.db.composites.Composite;
+import org.apache.cassandra.db.composites.CType;
 import org.apache.cassandra.io.ISerializer;
 import org.apache.cassandra.io.IVersionedSerializer;
 import org.apache.cassandra.io.sstable.SSTableReader;
@@ -131,11 +132,11 @@ public class NamesQueryFilter implements IDiskAtomFilter
         return count;
     }
 
-    public boolean maySelectPrefix(Comparator<Composite> cmp, Composite prefix)
+    public boolean maySelectPrefix(CType type, Composite prefix)
     {
         for (CellName column : columns)
         {
-            if (prefix.isPrefixOf(column))
+            if (prefix.isPrefixOf(type, column))
                 return true;
         }
         return false;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb81f74/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java b/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
index 7add2b8..3d3e820 100644
--- a/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
+++ b/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
@@ -334,10 +334,10 @@ public class SliceQueryFilter implements IDiskAtomFilter
         count = newLimit;
     }
 
-    public boolean maySelectPrefix(Comparator<Composite> cmp, Composite prefix)
+    public boolean maySelectPrefix(CType type, Composite prefix)
     {
         for (ColumnSlice slice : slices)
-            if (slice.includes(cmp, prefix))
+            if (slice.includes(type, prefix))
                 return true;
         return false;
     }


Mime
View raw message