You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2015/02/04 17:52:13 UTC

cassandra git commit: Fix reversal of list prepends

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 2dd6944f1 -> 2d8bddb06


Fix reversal of list prepends

Patch by Tyler Hobbs; reviewed by Sylvain Lebresne for CASSANDRA-8733


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

Branch: refs/heads/cassandra-2.0
Commit: 2d8bddb064f2a6f9292878e2d40805d9db74a09d
Parents: 2dd6944
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Wed Feb 4 10:51:24 2015 -0600
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Wed Feb 4 10:51:24 2015 -0600

----------------------------------------------------------------------
 CHANGES.txt                                   | 1 +
 NEWS.txt                                      | 9 +++++++++
 src/java/org/apache/cassandra/cql3/Lists.java | 4 ++--
 3 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d8bddb0/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9e9b772..375dcfe 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.13:
+ * Fix reversal of list prepends (CASSANDRA-8733)
  * Prevent non-zero default_time_to_live on tables with counters
    (CASSANDRA-8678)
  * Fix SSTableSimpleUnsortedWriter ConcurrentModificationException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d8bddb0/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index 2bc4fe6..5a4bc3d 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -13,6 +13,15 @@ restore snapshots created with the previous major version using the
 'sstableloader' tool. You can upgrade the file format of your snapshots
 using the provided 'sstableupgrade' tool.
 
+2.0.13
+======
+
+Upgrading
+---------
+    - Prepending a list to a list collection was erroneously resulting in
+      the prepended list being reversed upon insertion.  If you were depending
+      on this buggy behavior, note that it has been corrected.
+
 2.0.12
 ======
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d8bddb0/src/java/org/apache/cassandra/cql3/Lists.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Lists.java b/src/java/org/apache/cassandra/cql3/Lists.java
index d483dd5..f4d1d7a 100644
--- a/src/java/org/apache/cassandra/cql3/Lists.java
+++ b/src/java/org/apache/cassandra/cql3/Lists.java
@@ -385,9 +385,9 @@ public abstract class Lists
 
             List<ByteBuffer> toAdd = ((Lists.Value)value).elements;
             ColumnNameBuilder column = maybeUpdatePrefix(cf.metadata(), prefix).add(columnName.key);
-            for (int i = 0; i < toAdd.size(); i++)
+            for (int i = toAdd.size() - 1; i >= 0; i--)
             {
-                ColumnNameBuilder b = i == toAdd.size() - 1 ? column : column.copy();
+                ColumnNameBuilder b = i == 0 ? column : column.copy();
                 PrecisionTime pt = PrecisionTime.getNext(time);
                 ByteBuffer uuid = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes(pt.millis, pt.nanos));
                 ByteBuffer cellName = b.add(uuid).build();