cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [1/2] cassandra git commit: Only calculate maxPurgableTimestamp if we know there are tombstones
Date Mon, 23 Mar 2015 08:21:16 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk fb3d9fd85 -> 6633421dd


Only calculate maxPurgableTimestamp if we know there are tombstones

Patch by marcuse; reviewed by Sylvain Lebresne for CASSANDRA-8914


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

Branch: refs/heads/trunk
Commit: fd0bdef5abb9c7fb4318b7c4c989cb90d352a19b
Parents: 6c69f9a
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Fri Mar 6 17:34:28 2015 +0100
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Mon Mar 23 09:07:42 2015 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../db/compaction/LazilyCompactedRow.java       | 31 ++++++++++++++------
 2 files changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/fd0bdef5/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 03f7e1c..25b0a06 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.4
+ * Only calculate max purgable timestamp if we have to (CASSANDRA-8914)
  * (cqlsh) Greatly improve performance of COPY FROM (CASSANDRA-8225)
  * IndexSummary effectiveIndexInterval is now a guideline, not a rule (CASSANDRA-8993)
  * Use correct bounds for page cache eviction of compressed files (CASSANDRA-8746)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fd0bdef5/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java b/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java
index cfdbd17..f61225a 100644
--- a/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java
+++ b/src/java/org/apache/cassandra/db/compaction/LazilyCompactedRow.java
@@ -50,7 +50,8 @@ public class LazilyCompactedRow extends AbstractCompactedRow
 {
     private final List<? extends OnDiskAtomIterator> rows;
     private final CompactionController controller;
-    private final long maxPurgeableTimestamp;
+    private boolean hasCalculatedMaxPurgeableTimestamp = false;
+    private long maxPurgeableTimestamp;
     private final ColumnFamily emptyColumnFamily;
     private ColumnStats columnStats;
     private boolean closed;
@@ -77,19 +78,29 @@ public class LazilyCompactedRow extends AbstractCompactedRow
                 maxRowTombstone = rowTombstone;
         }
 
-        // tombstones with a localDeletionTime before this can be purged.  This is the minimum
timestamp for any sstable
-        // containing `key` outside of the set of sstables involved in this compaction.
-        maxPurgeableTimestamp = controller.maxPurgeableTimestamp(key);
-
         emptyColumnFamily = ArrayBackedSortedColumns.factory.create(controller.cfs.metadata);
         emptyColumnFamily.delete(maxRowTombstone);
-        if (maxRowTombstone.markedForDeleteAt < maxPurgeableTimestamp)
+        if (!maxRowTombstone.isLive() && maxRowTombstone.markedForDeleteAt < getMaxPurgeableTimestamp())
             emptyColumnFamily.purgeTombstones(controller.gcBefore);
 
         reducer = new Reducer();
         merger = Iterators.filter(MergeIterator.get(rows, emptyColumnFamily.getComparator().onDiskAtomComparator(),
reducer), Predicates.notNull());
     }
 
+    /**
+     * tombstones with a localDeletionTime before this can be purged.  This is the minimum
timestamp for any sstable
+     * containing `key` outside of the set of sstables involved in this compaction.
+     */
+    private long getMaxPurgeableTimestamp()
+    {
+        if (!hasCalculatedMaxPurgeableTimestamp)
+        {
+            hasCalculatedMaxPurgeableTimestamp = true;
+            maxPurgeableTimestamp = controller.maxPurgeableTimestamp(key);
+        }
+        return maxPurgeableTimestamp;
+    }
+
     private static void removeDeleted(ColumnFamily cf, boolean shouldPurge, DecoratedKey
key, CompactionController controller)
     {
         // We should only purge cell tombstones if shouldPurge is true, but regardless, it's
still ok to remove cells that
@@ -251,7 +262,7 @@ public class LazilyCompactedRow extends AbstractCompactedRow
                 RangeTombstone t = tombstone;
                 tombstone = null;
 
-                if (t.timestamp() < maxPurgeableTimestamp && t.data.isGcAble(controller.gcBefore))
+                if (t.timestamp() < getMaxPurgeableTimestamp() && t.data.isGcAble(controller.gcBefore))
                 {
                     indexBuilder.tombstoneTracker().update(t, true);
                     return null;
@@ -269,11 +280,13 @@ public class LazilyCompactedRow extends AbstractCompactedRow
             }
             else
             {
-                boolean shouldPurge = container.getSortedColumns().iterator().next().timestamp()
< maxPurgeableTimestamp;
                 // when we clear() the container, it removes the deletion info, so this needs
to be reset each time
                 container.delete(maxRowTombstone);
-                removeDeleted(container, shouldPurge, key, controller);
                 Iterator<Cell> iter = container.iterator();
+                Cell c = iter.next();
+                boolean shouldPurge = c.getLocalDeletionTime() < Integer.MAX_VALUE &&
c.timestamp() < getMaxPurgeableTimestamp();
+                removeDeleted(container, shouldPurge, key, controller);
+                iter = container.iterator();
                 if (!iter.hasNext())
                 {
                     // don't call clear() because that resets the deletion time. See CASSANDRA-7808.


Mime
View raw message