cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [1/5] git commit: Fix deletion for indexes on primary key columns
Date Tue, 04 Nov 2014 18:31:42 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 525ac00c0 -> 07068e204


Fix deletion for indexes on primary key columns

patch by slebresne; reviewed by thobbs for CASSANDRA-8206


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

Branch: refs/heads/trunk
Commit: c345f81e7fca246677efb9f3073eb903ce8054f0
Parents: e88bcfe
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Tue Nov 4 18:36:53 2014 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Tue Nov 4 18:37:25 2014 +0100

----------------------------------------------------------------------
 CHANGES.txt                                                  | 1 +
 .../db/index/AbstractSimplePerColumnSecondaryIndex.java      | 5 +++++
 .../apache/cassandra/db/index/PerColumnSecondaryIndex.java   | 7 ++++++-
 src/java/org/apache/cassandra/db/index/SecondaryIndex.java   | 7 +++++++
 .../org/apache/cassandra/db/index/SecondaryIndexManager.java | 4 ++--
 .../db/index/composites/CompositesIndexOnClusteringKey.java  | 8 ++++++++
 .../db/index/composites/CompositesIndexOnPartitionKey.java   | 8 ++++++++
 7 files changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c345f81e/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 97fb94a..2fe3a39 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.12:
+ * Fix deletion for indexes on primary key columns (CASSANDRA-8206)
  * Add 'nodetool statusgossip' (CASSANDRA-8125)
  * Improve client notification that nodes are ready for requests (CASSANDRA-7510)
  * Handle negative timestamp in writetime method (CASSANDRA-8139)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c345f81e/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
index 87e87cb..553b9d4 100644
--- a/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
+++ b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
@@ -78,6 +78,11 @@ public abstract class AbstractSimplePerColumnSecondaryIndex extends PerColumnSec
 
     public void delete(ByteBuffer rowKey, Column column)
     {
+        deleteForCleanup(rowKey, column);
+    }
+
+    public void deleteForCleanup(ByteBuffer rowKey, Column column)
+    {
         if (column.isMarkedForDelete(System.currentTimeMillis()))
             return;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c345f81e/src/java/org/apache/cassandra/db/index/PerColumnSecondaryIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/PerColumnSecondaryIndex.java b/src/java/org/apache/cassandra/db/index/PerColumnSecondaryIndex.java
index e77bd0f..73f53f1 100644
--- a/src/java/org/apache/cassandra/db/index/PerColumnSecondaryIndex.java
+++ b/src/java/org/apache/cassandra/db/index/PerColumnSecondaryIndex.java
@@ -29,7 +29,7 @@ import org.apache.cassandra.utils.FBUtilities;
 public abstract class PerColumnSecondaryIndex extends SecondaryIndex
 {
     /**
-     * Delete a column from the index
+     * Called when a column has been tombstoned or replaced.
      *
      * @param rowKey the underlying row key which is indexed
      * @param col all the column info
@@ -37,6 +37,11 @@ public abstract class PerColumnSecondaryIndex extends SecondaryIndex
     public abstract void delete(ByteBuffer rowKey, Column col);
 
     /**
+     * Called when a column has been removed due to a cleanup operation.
+     */
+    public abstract void deleteForCleanup(ByteBuffer rowKey, Column col);
+
+    /**
      * insert a column to the index
      *
      * @param rowKey the underlying row key which is indexed

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c345f81e/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/SecondaryIndex.java b/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
index 64266c4..a83f5dd 100644
--- a/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
+++ b/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
@@ -21,6 +21,7 @@ import java.nio.ByteBuffer;
 import java.util.*;
 import java.util.concurrent.*;
 
+import com.google.common.base.Objects;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -371,4 +372,10 @@ public abstract class SecondaryIndex
         }
         throw new AssertionError();
     }
+
+    @Override
+    public String toString()
+    {
+        return Objects.toStringHelper(this).add("columnDefs", columnDefs).toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c345f81e/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
index b75f917..6d9f28a 100644
--- a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
+++ b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
@@ -465,7 +465,7 @@ public class SecondaryIndexManager
                 }
                 else
                 {
-                    ((PerColumnSecondaryIndex) index).delete(key.key, column);
+                    ((PerColumnSecondaryIndex) index).deleteForCleanup(key.key, column);
                 }
             }
         }
@@ -618,7 +618,7 @@ public class SecondaryIndexManager
         {
             if (oldColumn.equals(column))
                 return;
-            
+
             for (SecondaryIndex index : indexFor(column.name()))
             {
                 if (index instanceof PerColumnSecondaryIndex)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c345f81e/src/java/org/apache/cassandra/db/index/composites/CompositesIndexOnClusteringKey.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/composites/CompositesIndexOnClusteringKey.java
b/src/java/org/apache/cassandra/db/index/composites/CompositesIndexOnClusteringKey.java
index 954f380..564d6bb 100644
--- a/src/java/org/apache/cassandra/db/index/composites/CompositesIndexOnClusteringKey.java
+++ b/src/java/org/apache/cassandra/db/index/composites/CompositesIndexOnClusteringKey.java
@@ -112,4 +112,12 @@ public class CompositesIndexOnClusteringKey extends CompositesIndex
     {
         return data.hasOnlyTombstones(now);
     }
+
+    @Override
+    public void delete(ByteBuffer rowKey, Column column)
+    {
+        // We only know that one column of the CQL row has been updated/deleted, but we don't
know if the
+        // full row has been deleted so we should not do anything. If it ends up that the
whole row has
+        // been deleted, it will be eventually cleaned up on read because the entry will
be detected stale.
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c345f81e/src/java/org/apache/cassandra/db/index/composites/CompositesIndexOnPartitionKey.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/composites/CompositesIndexOnPartitionKey.java
b/src/java/org/apache/cassandra/db/index/composites/CompositesIndexOnPartitionKey.java
index 4e2c580..e8956dc 100644
--- a/src/java/org/apache/cassandra/db/index/composites/CompositesIndexOnPartitionKey.java
+++ b/src/java/org/apache/cassandra/db/index/composites/CompositesIndexOnPartitionKey.java
@@ -99,4 +99,12 @@ public class CompositesIndexOnPartitionKey extends CompositesIndex
     {
         return data.hasOnlyTombstones(now);
     }
+
+    @Override
+    public void delete(ByteBuffer rowKey, Column column)
+    {
+        // We only know that one column of the CQL row has been updated/deleted, but we don't
know if the
+        // full row has been deleted so we should not do anything. If it ends up that the
whole row has
+        // been deleted, it will be eventually cleaned up on read because the entry will
be detected stale.
+    }
 }


Mime
View raw message