cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject cassandra git commit: Backport CASSANDRA-6863 without digest updates
Date Tue, 07 Apr 2015 17:50:59 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 67038a32e -> 922a2c49b


Backport CASSANDRA-6863 without digest updates

patch by Carl Yeksigan; reviewed by Sam Tunnicliffe for CASSANDRA-8989


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

Branch: refs/heads/cassandra-2.0
Commit: 922a2c49b6de281c95b0ef05481c076bf2abd077
Parents: 67038a3
Author: Carl Yeksigian <carl@apache.org>
Authored: Thu Mar 26 12:19:16 2015 -0400
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Tue Apr 7 17:07:40 2015 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/cassandra/db/ColumnFamily.java   |  2 +
 .../org/apache/cassandra/db/DeletionInfo.java   | 16 ++++++++
 .../apache/cassandra/db/RangeTombstoneList.java | 39 +++++++++++++++++++
 test/unit/org/apache/cassandra/Util.java        |  5 +++
 test/unit/org/apache/cassandra/db/RowTest.java  | 41 ++++++++++++++++++--
 6 files changed, 100 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/922a2c49/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 28f79f9..8815a92 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.15:
+ * Backport CASSANDRA-6863 without digest updates (CASSANDRA-8989)
  * Don't include tmp files when doing offline relevel (CASSANDRA-9088)
  * Use the proper CAS WriteType when finishing a previous round during Paxos
    preparation (CASSANDRA-8672)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/922a2c49/src/java/org/apache/cassandra/db/ColumnFamily.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamily.java b/src/java/org/apache/cassandra/db/ColumnFamily.java
index 38c72e0..a294525 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamily.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamily.java
@@ -321,6 +321,8 @@ public abstract class ColumnFamily implements Iterable<Column>,
IRowCacheEntry
             }
         }
 
+        cfDiff.setDeletionInfo(deletionInfo().diff(cfComposite.deletionInfo()));
+
         if (!cfDiff.isEmpty())
             return cfDiff;
         return null;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/922a2c49/src/java/org/apache/cassandra/db/DeletionInfo.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DeletionInfo.java b/src/java/org/apache/cassandra/db/DeletionInfo.java
index 23f46bf..27811b3 100644
--- a/src/java/org/apache/cassandra/db/DeletionInfo.java
+++ b/src/java/org/apache/cassandra/db/DeletionInfo.java
@@ -171,6 +171,22 @@ public class DeletionInfo
     }
 
     /**
+     * Evaluates difference between this deletion info and superset for read repair
+     *
+     * @return the difference between the two, or LIVE if no difference
+     */
+    public DeletionInfo diff(DeletionInfo superset)
+    {
+        RangeTombstoneList rangeDiff = superset.ranges == null || superset.ranges.isEmpty()
+                                     ? null
+                                     : ranges == null ? superset.ranges : ranges.diff(superset.ranges);
+
+        return topLevel.markedForDeleteAt != superset.topLevel.markedForDeleteAt || rangeDiff
!= null
+             ? new DeletionInfo(superset.topLevel, rangeDiff)
+             : DeletionInfo.live();
+    }
+
+    /**
      * Returns true if {@code purge} would remove the top-level tombstone or any of the range
      * tombstones, false otherwise.
      * @param gcBefore timestamp (in seconds) before which tombstones should be purged

http://git-wip-us.apache.org/repos/asf/cassandra/blob/922a2c49/src/java/org/apache/cassandra/db/RangeTombstoneList.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RangeTombstoneList.java b/src/java/org/apache/cassandra/db/RangeTombstoneList.java
index dadcc20..b49c2fc 100644
--- a/src/java/org/apache/cassandra/db/RangeTombstoneList.java
+++ b/src/java/org/apache/cassandra/db/RangeTombstoneList.java
@@ -333,6 +333,45 @@ public class RangeTombstoneList implements Iterable<RangeTombstone>
         };
     }
 
+    /**
+     * Evaluates a diff between superset (known to be all merged tombstones) and this list
for read repair
+     *
+     * @return null if there is no difference
+     */
+    public RangeTombstoneList diff(RangeTombstoneList superset)
+    {
+        if (isEmpty())
+            return superset;
+
+        assert size <= superset.size;
+
+        RangeTombstoneList diff = null;
+
+        int j = 0; // index to iterate through our own list
+        for (int i = 0; i < superset.size; i++)
+        {
+            boolean sameStart = j < size && starts[j].equals(superset.starts[i]);
+            // don't care about local deletion time here. for RR it doesn't makes sense
+            if (!sameStart
+                || !ends[j].equals(superset.ends[i])
+                || markedAts[j] != superset.markedAts[i])
+            {
+                if (diff == null)
+                    diff = new RangeTombstoneList(comparator, Math.min(8, superset.size -
i));
+                diff.add(superset.starts[i], superset.ends[i], superset.markedAts[i], superset.delTimes[i]);
+
+                if (sameStart)
+                    j++;
+            }
+            else
+            {
+                j++;
+            }
+        }
+
+        return diff;
+    }
+
     @Override
     public boolean equals(Object o)
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/922a2c49/test/unit/org/apache/cassandra/Util.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/Util.java b/test/unit/org/apache/cassandra/Util.java
index a71dc48..76afa37 100644
--- a/test/unit/org/apache/cassandra/Util.java
+++ b/test/unit/org/apache/cassandra/Util.java
@@ -281,4 +281,9 @@ public class Util
 
         assert thrown : exception.getName() + " not received";
     }
+
+    public static RangeTombstone tombstone(String start, String finish, long timestamp, int
localtime)
+    {
+        return new RangeTombstone(ByteBufferUtil.bytes(start), ByteBufferUtil.bytes(finish),
timestamp , localtime);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/922a2c49/test/unit/org/apache/cassandra/db/RowTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RowTest.java b/test/unit/org/apache/cassandra/db/RowTest.java
index 2571fa5..c7c7023 100644
--- a/test/unit/org/apache/cassandra/db/RowTest.java
+++ b/test/unit/org/apache/cassandra/db/RowTest.java
@@ -21,15 +21,16 @@ package org.apache.cassandra.db;
 import java.util.Arrays;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.cassandra.SchemaLoader;
+import com.google.common.util.concurrent.Uninterruptibles;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.apache.cassandra.Util.column;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
-import com.google.common.util.concurrent.Uninterruptibles;
+import static org.junit.Assert.assertEquals;
 
+import static org.apache.cassandra.Util.column;
+import static org.apache.cassandra.Util.tombstone;
 
 public class RowTest extends SchemaLoader
 {
@@ -46,6 +47,38 @@ public class RowTest extends SchemaLoader
         ColumnFamily cfDiff = cf1.diff(cf2);
         assertEquals(cfDiff.getColumnCount(), 0);
         assertEquals(cfDiff.deletionInfo(), delInfo);
+
+        RangeTombstone tombstone1 = tombstone("1", "11", (long) 123, 123);
+        RangeTombstone tombstone1_2 = tombstone("111", "112", (long) 1230, 123);
+        RangeTombstone tombstone2_1 = tombstone("2", "22", (long) 123, 123);
+        RangeTombstone tombstone2_2 = tombstone("2", "24", (long) 123, 123);
+        RangeTombstone tombstone3_1 = tombstone("3", "31", (long) 123, 123);
+        RangeTombstone tombstone3_2 = tombstone("3", "31", (long) 1230, 123);
+        RangeTombstone tombstone4_1 = tombstone("4", "41", (long) 123, 123);
+        RangeTombstone tombstone4_2 = tombstone("4", "41", (long) 123, 1230);
+        RangeTombstone tombstone5_2 = tombstone("5", "51", (long) 123, 1230);
+        cf1.delete(tombstone1);
+        cf1.delete(tombstone2_1);
+        cf1.delete(tombstone3_1);
+        cf1.delete(tombstone4_1);
+
+        cf2.delete(tombstone1);
+        cf2.delete(tombstone1_2);
+        cf2.delete(tombstone2_2);
+        cf2.delete(tombstone3_2);
+        cf2.delete(tombstone4_2);
+        cf2.delete(tombstone5_2);
+
+        cfDiff = cf1.diff(cf2);
+        assertEquals(0, cfDiff.getColumnCount());
+
+        // only tmbstones which differ in superset or have more recent timestamp to be in
diff
+        delInfo.add(tombstone1_2, cf1.getComparator());
+        delInfo.add(tombstone2_2, cf1.getComparator());
+        delInfo.add(tombstone3_2, cf1.getComparator());
+        delInfo.add(tombstone5_2, cf1.getComparator());
+
+        assertEquals(delInfo, cfDiff.deletionInfo());
     }
 
     @Test


Mime
View raw message