cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [2/3] git commit: add SecondaryIndex.reload API patch by Sam Tunnicliffe; reviewed by jbellis for CASSANDRA-4581
Date Wed, 05 Sep 2012 21:41:16 GMT
add SecondaryIndex.reload API
patch by Sam Tunnicliffe; reviewed by jbellis for CASSANDRA-4581


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

Branch: refs/heads/trunk
Commit: 2cd73633bd441697979e9bfe4af0ca20527c6a89
Parents: ec1c64a
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Wed Sep 5 16:08:27 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Wed Sep 5 16:24:24 2012 -0500

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../apache/cassandra/db/index/SecondaryIndex.java  |    8 ++++++++
 .../cassandra/db/index/SecondaryIndexManager.java  |    7 ++++---
 .../apache/cassandra/db/index/keys/KeysIndex.java  |    6 ++++++
 .../cassandra/db/SecondaryIndexColumnSizeTest.java |   13 +++++++++++--
 5 files changed, 30 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2cd73633/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 75e856c..04fa0bf 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.1.5
+ * add SecondaryIndex.reload API (CASSANDRA-4581)
  * use millis + atomicint for commitlog segment creation instead of
    nanotime, which has issues under some hypervisors (CASSANDRA-4601)
  * fix FD leak in slice queries (CASSANDRA-4571)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2cd73633/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 3732086..8d734ff 100644
--- a/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
+++ b/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
@@ -66,6 +66,14 @@ public abstract class SecondaryIndex
     public abstract void init();
 
     /**
+     * Reload an existing index following a change to its configuration, 
+     * or that of the indexed column(s). Differs from init() in that we expect
+     * expect new resources (such as CFS for a KEYS index) to be created by
+     * init() but not here
+     */
+    public abstract void reload() throws IOException;
+
+    /**
      * Validates the index_options passed in the ColumnDef
      * @throws ConfigurationException
      */

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2cd73633/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 7258835..15064c7 100644
--- a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
+++ b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
@@ -99,10 +99,11 @@ public class SecondaryIndexManager
             if (cdef.getIndexType() != null && !indexedColumnNames.contains(cdef.name))
                 addIndexedColumn(cdef);
 
-        for (ColumnFamilyStore cfs : getIndexesBackedByCfs())
+        Set<SecondaryIndex> reloadedIndexes = Collections.newSetFromMap(new IdentityHashMap<SecondaryIndex,
Boolean>());
+        for (SecondaryIndex index : indexesByColumn.values())
         {
-            cfs.metadata.reloadSecondaryIndexMetadata(baseCfs.metadata);
-            cfs.reload();
+            if (reloadedIndexes.add(index))
+                index.reload();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2cd73633/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java b/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
index 3ee782b..bbdedce 100644
--- a/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
+++ b/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
@@ -181,4 +181,10 @@ public class KeysIndex extends PerColumnSecondaryIndex
     {
         return indexCfs.getMemtableDataSize();
     }
+
+    public void reload() throws IOException
+    {
+        indexCfs.metadata.reloadSecondaryIndexMetadata(baseCfs.metadata);
+        indexCfs.reload();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2cd73633/test/unit/org/apache/cassandra/db/SecondaryIndexColumnSizeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/SecondaryIndexColumnSizeTest.java b/test/unit/org/apache/cassandra/db/SecondaryIndexColumnSizeTest.java
index 89479e9..645131b 100644
--- a/test/unit/org/apache/cassandra/db/SecondaryIndexColumnSizeTest.java
+++ b/test/unit/org/apache/cassandra/db/SecondaryIndexColumnSizeTest.java
@@ -137,7 +137,11 @@ public class SecondaryIndexColumnSizeTest
         public void deleteFromIndex(DecoratedKey<?> key, List<IColumn> indexedColumnsInRow)
         {  
         }
-        
+
+        @Override
+        public void reload()
+        {
+        }
     }
     
     
@@ -210,6 +214,11 @@ public class SecondaryIndexColumnSizeTest
         @Override
         public void updateColumn(DecoratedKey valueKey, ByteBuffer rowKey, IColumn col) throws
IOException
         {
-        }    
+        }
+
+        @Override
+        public void reload()
+        {
+        }
     }
 }


Mime
View raw message