You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2014/08/18 14:25:53 UTC

[1/2] git commit: Fix ordering of static cells

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 5549680e7 -> f454fecf6


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/cassandra-2.1
Commit: 56db00180f588cd3a5da7ae5861eefda00fbac56
Parents: 1f54010
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Mon Aug 18 14:18:02 2014 +0200
Committer: Sylvain Lebresne <sy...@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);


[2/2] git commit: Merge branch 'cassandra-2.1.0' into cassandra-2.1

Posted by sl...@apache.org.
Merge branch 'cassandra-2.1.0' into cassandra-2.1


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

Branch: refs/heads/cassandra-2.1
Commit: f454fecf6ed11ff27c2b6b472ba0b1c88dcc1985
Parents: 5549680 56db001
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Mon Aug 18 14:25:29 2014 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Mon Aug 18 14:25:29 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/db/AbstractNativeCell.java | 11 ++++++++++
 .../cassandra/db/composites/AbstractCType.java  | 22 ++++++++++++++++++++
 .../composites/CompoundSparseCellNameType.java  | 11 ++++++++++
 4 files changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f454fecf/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 2e6b184,8aafd98..9ab4109
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,34 -1,5 +1,35 @@@
 +2.1.1
 + * Support list index operations with conditions (CASSANDRA-7499)
 + * Add max live/tombstoned cells to nodetool cfstats output (CASSANDRA-7731)
 + * Validate IPv6 wildcard addresses properly (CASSANDRA-7680)
 + * (cqlsh) Error when tracing query (CASSANDRA-7613)
 + * Avoid IOOBE when building SyntaxError message snippet (CASSANDRA-7569)
 + * SSTableExport uses correct validator to create string representation of partition
 +   keys (CASSANDRA-7498)
 + * Avoid NPEs when receiving type changes for an unknown keyspace (CASSANDRA-7689)
 + * Add support for custom 2i validation (CASSANDRA-7575)
 + * Pig support for hadoop CqlInputFormat (CASSANDRA-6454)
 + * Add listen_interface and rpc_interface options (CASSANDRA-7417)
 + * Improve schema merge performance (CASSANDRA-7444)
 + * Adjust MT depth based on # of partition validating (CASSANDRA-5263)
 + * Optimise NativeCell comparisons (CASSANDRA-6755)
 + * Configurable client timeout for cqlsh (CASSANDRA-7516)
 + * Include snippet of CQL query near syntax error in messages (CASSANDRA-7111)
 +Merged from 2.0:
 + * (Hadoop) allow ACFRW to limit nodes to local DC (CASSANDRA-7252)
 + * (cqlsh) cqlsh should automatically disable tracing when selecting
 +   from system_traces (CASSANDRA-7641)
 + * (Hadoop) Add CqlOutputFormat (CASSANDRA-6927)
 + * Don't depend on cassandra config for nodetool ring (CASSANDRA-7508)
 + * (cqlsh) Fix failing cqlsh formatting tests (CASSANDRA-7703)
 + * Fix IncompatibleClassChangeError from hadoop2 (CASSANDRA-7229)
 + * Add 'nodetool sethintedhandoffthrottlekb' (CASSANDRA-7635)
 + * (cqlsh) Add tab-completion for CREATE/DROP USER IF [NOT] EXISTS (CASSANDRA-7611)
 + * Catch errors when the JVM pulls the rug out from GCInspector (CASSANDRA-5345)
 + * cqlsh fails when version number parts are not int (CASSANDRA-7524)
 +
  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/f454fecf/src/java/org/apache/cassandra/db/AbstractNativeCell.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/AbstractNativeCell.java
index d79ad19,f3128b8..7e85af3
--- a/src/java/org/apache/cassandra/db/AbstractNativeCell.java
+++ b/src/java/org/apache/cassandra/db/AbstractNativeCell.java
@@@ -658,38 -645,4 +658,49 @@@ public abstract class AbstractNativeCel
          checkPosition(offset, length);
          return MemoryUtil.getByteBuffer(peer + offset, length);
      }
 +
 +    // requires isByteOrderComparable to be true. Compares the name components only; ; may need to compare EOC etc still
 +    public final int compareTo(final Composite that)
 +    {
++        if (isStatic() != that.isStatic())
++        {
++            // Static sorts before non-static no matter what, except for empty which
++            // always sort first
++            if (isEmpty())
++                return that.isEmpty() ? 0 : -1;
++            if (that.isEmpty())
++                return 1;
++            return isStatic() ? -1 : 1;
++        }
++
 +        int size = size();
 +        int size2 = that.size();
 +        int minSize = Math.min(size, size2);
 +        int startDelta = 0;
 +        int cellNamesOffset = nameDeltaOffset(size);
 +        for (int i = 0 ; i < minSize ; i++)
 +        {
 +            int endDelta = i < size - 1 ? getShort(nameDeltaOffset(i + 1)) : valueStartOffset() - cellNamesOffset;
 +            long offset = peer + cellNamesOffset + startDelta;
 +            int length = endDelta - startDelta;
 +            int cmp = FastByteOperations.UnsafeOperations.compareTo(null, offset, length, that.get(i));
 +            if (cmp != 0)
 +                return cmp;
 +            startDelta = endDelta;
 +        }
 +
 +        EOC eoc = that.eoc();
 +        if (size == size2)
 +            return this.eoc().compareTo(eoc);
 +
 +        return size < size2 ? this.eoc().prefixComparisonResult : -eoc.prefixComparisonResult;
 +    }
 +
 +    public final int compareToSimple(final Composite that)
 +    {
 +        assert size() == 1 && that.size() == 1;
 +        int length = valueStartOffset() - nameDeltaOffset(1);
 +        long offset = peer + nameDeltaOffset(1);
 +        return FastByteOperations.UnsafeOperations.compareTo(null, offset, length, that.get(0));
 +    }
  }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f454fecf/src/java/org/apache/cassandra/db/composites/AbstractCType.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/composites/AbstractCType.java
index 491a9d1,0e206c7..5af7458
--- a/src/java/org/apache/cassandra/db/composites/AbstractCType.java
+++ b/src/java/org/apache/cassandra/db/composites/AbstractCType.java
@@@ -132,37 -102,41 +132,59 @@@ public abstract class AbstractCType imp
          return isByteOrderComparable;
      }
  
 -    public int compare(Composite c1, Composite c2)
 +    static int compareUnsigned(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);
  
 -        if (isByteOrderComparable)
 +        for (int i = 0; i < minSize; i++)
          {
 -            for (int i = 0; i < minSize; i++)
 -            {
 -                int cmp = ByteBufferUtil.compareUnsigned(c1.get(i), c2.get(i));
 -                if (cmp != 0)
 -                    return cmp;
 -            }
 +            int cmp = ByteBufferUtil.compareUnsigned(c1.get(i), c2.get(i));
 +            if (cmp != 0)
 +                return cmp;
          }
 -        else
 +
 +        if (s1 == s2)
 +            return c1.eoc().compareTo(c2.eoc());
 +        return s1 < s2 ? c1.eoc().prefixComparisonResult : -c2.eoc().prefixComparisonResult;
 +    }
 +
 +    public int compare(Composite c1, Composite c2)
 +    {
++        if (c1.isStatic() != c2.isStatic())
+         {
 -            for (int i = 0; i < minSize; i++)
 -            {
 -                AbstractType<?> comparator = subtype(i);
 -                int cmp = comparator.compare(c1.get(i), c2.get(i));
 -                if (cmp != 0)
 -                    return cmp;
 -            }
++            // 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);
 +
 +        for (int i = 0; i < minSize; i++)
 +        {
 +            int cmp = isByteOrderComparable
 +                      ? ByteBufferUtil.compareUnsigned(c1.get(i), c2.get(i))
 +                      : subtype(i).compare(c1.get(i), c2.get(i));
 +            if (cmp != 0)
 +                return cmp;
          }
  
          if (s1 == s2)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f454fecf/src/java/org/apache/cassandra/db/composites/CompoundSparseCellNameType.java
----------------------------------------------------------------------