cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject git commit: Improve custom 2i performance and abstraction Patch by Miguel Angel Fernandez Diaz, reviewed by Sam Tunnicliffe for CASSANDRA-6640
Date Mon, 03 Feb 2014 17:36:19 GMT
Updated Branches:
  refs/heads/trunk aa29b6af6 -> fc91071c0


Improve custom 2i performance and abstraction
Patch by Miguel Angel Fernandez Diaz, reviewed by Sam Tunnicliffe for
CASSANDRA-6640


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

Branch: refs/heads/trunk
Commit: fc91071c01c33500774de83944bf5f937397c089
Parents: aa29b6a
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Mon Feb 3 11:33:37 2014 -0600
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Mon Feb 3 11:33:37 2014 -0600

----------------------------------------------------------------------
 .../db/index/AbstractSimplePerColumnSecondaryIndex.java       | 7 +++++--
 .../apache/cassandra/db/index/PerColumnSecondaryIndex.java    | 3 ++-
 .../org/apache/cassandra/db/index/SecondaryIndexManager.java  | 7 +++----
 test/unit/org/apache/cassandra/db/RangeTombstoneTest.java     | 2 +-
 .../org/apache/cassandra/db/SecondaryIndexCellSizeTest.java   | 2 +-
 5 files changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/fc91071c/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 5987d7a..e2a6608 100644
--- a/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
+++ b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
@@ -135,9 +135,12 @@ public abstract class AbstractSimplePerColumnSecondaryIndex extends PerColumnSec
         indexCfs.apply(valueKey, cfi, SecondaryIndexManager.nullUpdater, opGroup, null);
     }
 
-    public void update(ByteBuffer rowKey, Cell col, OpOrder.Group opGroup)
-    {
+    public void update(ByteBuffer rowKey, Cell oldCol, Cell col, OpOrder.Group opGroup)
+    {        
+        // insert the new value before removing the old one, so we never have a period
+        // where the row is invisible to both queries (the opposite seems preferable); see
CASSANDRA-5540                    
         insert(rowKey, col, opGroup);
+        delete(rowKey, oldCol, opGroup);
     }
 
     public void removeIndex(ByteBuffer columnName)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fc91071c/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 e094c4c..79087d2 100644
--- a/src/java/org/apache/cassandra/db/index/PerColumnSecondaryIndex.java
+++ b/src/java/org/apache/cassandra/db/index/PerColumnSecondaryIndex.java
@@ -49,9 +49,10 @@ public abstract class PerColumnSecondaryIndex extends SecondaryIndex
      * update a column from the index
      *
      * @param rowKey the underlying row key which is indexed
+     * @param oldCol the previous column info
      * @param col all the column info
      */
-    public abstract void update(ByteBuffer rowKey, Cell col, OpOrder.Group opGroup);
+    public abstract void update(ByteBuffer rowKey, Cell oldCol, Cell col, OpOrder.Group opGroup);
 
     public String getNameForSystemKeyspace(ByteBuffer column)
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fc91071c/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 66e549d..946e3be 100644
--- a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
+++ b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
@@ -676,11 +676,10 @@ public class SecondaryIndexManager
             {
                 if (index instanceof PerColumnSecondaryIndex)
                 {
-                    // insert the new value before removing the old one, so we never have
a period
-                    // where the row is invisible to both queries (the opposite seems preferable);
see CASSANDRA-5540
                     if (!cell.isMarkedForDelete(System.currentTimeMillis()))
-                        ((PerColumnSecondaryIndex) index).insert(key.key, cell, opGroup);
-                    ((PerColumnSecondaryIndex) index).delete(key.key, oldCell, opGroup);
+                        ((PerColumnSecondaryIndex) index).update(key.key, oldCell, cell,
opGroup);
+                    else
+                        ((PerColumnSecondaryIndex) index).delete(key.key, oldCell, opGroup);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fc91071c/test/unit/org/apache/cassandra/db/RangeTombstoneTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RangeTombstoneTest.java b/test/unit/org/apache/cassandra/db/RangeTombstoneTest.java
index b859023..1885716 100644
--- a/test/unit/org/apache/cassandra/db/RangeTombstoneTest.java
+++ b/test/unit/org/apache/cassandra/db/RangeTombstoneTest.java
@@ -452,7 +452,7 @@ public class RangeTombstoneTest extends SchemaLoader
             inserts.add(col);
         }
 
-        public void update(ByteBuffer rowKey, Cell col, OpOrder.Group opGroup){}
+        public void update(ByteBuffer rowKey, Cell oldCol, Cell col, OpOrder.Group opGroup){}
 
         public void init(){}
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fc91071c/test/unit/org/apache/cassandra/db/SecondaryIndexCellSizeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/SecondaryIndexCellSizeTest.java b/test/unit/org/apache/cassandra/db/SecondaryIndexCellSizeTest.java
index 87ae58b..220e3b9 100644
--- a/test/unit/org/apache/cassandra/db/SecondaryIndexCellSizeTest.java
+++ b/test/unit/org/apache/cassandra/db/SecondaryIndexCellSizeTest.java
@@ -209,7 +209,7 @@ public class SecondaryIndexCellSizeTest
         }
 
         @Override
-        public void update(ByteBuffer rowKey, Cell col, OpOrder.Group opGroup)
+        public void update(ByteBuffer rowKey, Cell oldCol, Cell col, OpOrder.Group opGroup)
         {
         }
 


Mime
View raw message