cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1187049 - in /cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index: SecondaryIndexManager.java keys/KeysIndex.java
Date Thu, 20 Oct 2011 21:02:56 GMT
Author: jbellis
Date: Thu Oct 20 21:02:55 2011
New Revision: 1187049

URL: http://svn.apache.org/viewvc?rev=1187049&view=rev
Log:
cleanup
patch by jbellis

Modified:
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java?rev=1187049&r1=1187048&r2=1187049&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
Thu Oct 20 21:02:55 2011
@@ -153,20 +153,18 @@ public class SecondaryIndexManager
         if (index == null)
             return;
         
-        SystemTable.setIndexRemoved(baseCfs.metadata.ksName, index.getNameForSystemTable(column));
-        
-        index.removeIndex(column);
-        
         // Remove this column from from row level index map
         if (index instanceof PerRowSecondaryIndex)
         {
             index.removeColumnDef(column);
-            
+
             //If now columns left on this CF remove from row level lookup
             if (index.getColumnDefs().isEmpty())
                 rowLevelIndexMap.remove(index.getClass());
         }
-        
+
+        index.removeIndex(column);
+        SystemTable.setIndexRemoved(baseCfs.metadata.ksName, index.getNameForSystemTable(column));
     }
 
     /**
@@ -371,7 +369,7 @@ public class SecondaryIndexManager
                 SecondaryIndex index = getIndexForColumn(columnName);
                 assert index != null;               
 
-                //Update entire row if we encounter a row level index
+                // Update entire row if we encounter a row level index
                 if (index instanceof PerRowSecondaryIndex)
                 {
                     if (appliedRowLevelIndexes == null)
@@ -448,8 +446,7 @@ public class SecondaryIndexManager
             else
             {
                 DecoratedKey<LocalToken> valueKey = getIndexKeyFor(column.name(), column.value());
-
-                ((PerColumnSecondaryIndex)index).deleteColumn(valueKey, key.key, column);
+                ((PerColumnSecondaryIndex) index).deleteColumn(valueKey, key.key, column);
             }
         }       
     }

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java?rev=1187049&r1=1187048&r2=1187049&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
Thu Oct 20 21:02:55 2011
@@ -45,9 +45,8 @@ import org.slf4j.LoggerFactory;
 public class KeysIndex extends PerColumnSecondaryIndex
 {
     private static final Logger logger = LoggerFactory.getLogger(KeysIndex.class);
-    private ColumnFamilyStore indexedCfs;
-    private ColumnDefinition  columnDef;
-    
+    private ColumnFamilyStore indexCfs;
+
     public KeysIndex() 
     {
     }
@@ -55,11 +54,10 @@ public class KeysIndex extends PerColumn
     public void init()
     {
         assert baseCfs != null && columnDefs != null;
-        
-        columnDef = columnDefs.iterator().next();
-        
-        CFMetaData indexedCfMetadata = CFMetaData.newIndexMetadata(baseCfs.metadata, columnDef,
indexComparator());
-        indexedCfs = ColumnFamilyStore.createColumnFamilyStore(baseCfs.table,
+
+        ColumnDefinition columnDef = columnDefs.iterator().next();
+        CFMetaData indexedCfMetadata = CFMetaData.newIndexMetadata(baseCfs.metadata, columnDef,indexComparator());
+        indexCfs = ColumnFamilyStore.createColumnFamilyStore(baseCfs.table,
                                                                indexedCfMetadata.cfName,
                                                                new LocalPartitioner(columnDef.getValidator()),
                                                                indexedCfMetadata);
@@ -80,9 +78,9 @@ public class KeysIndex extends PerColumn
             return;
         
         int localDeletionTime = (int) (System.currentTimeMillis() / 1000);
-        ColumnFamily cfi = ColumnFamily.create(indexedCfs.metadata);
+        ColumnFamily cfi = ColumnFamily.create(indexCfs.metadata);
         cfi.addTombstone(rowKey, localDeletionTime, column.timestamp());
-        indexedCfs.apply(valueKey, cfi);
+        indexCfs.apply(valueKey, cfi);
         if (logger.isDebugEnabled())
             logger.debug("removed index entry for cleaned-up value {}:{}", valueKey, cfi);
     }
@@ -90,7 +88,7 @@ public class KeysIndex extends PerColumn
     @Override
     public void insertColumn(DecoratedKey<?> valueKey, ByteBuffer rowKey, IColumn column)
     {
-        ColumnFamily cfi = ColumnFamily.create(indexedCfs.metadata);
+        ColumnFamily cfi = ColumnFamily.create(indexCfs.metadata);
         if (column instanceof ExpiringColumn)
         {
             ExpiringColumn ec = (ExpiringColumn)column;
@@ -103,7 +101,7 @@ public class KeysIndex extends PerColumn
         if (logger.isDebugEnabled())
             logger.debug("applying index row {}:{}", valueKey, cfi);
         
-        indexedCfs.apply(valueKey, cfi);
+        indexCfs.apply(valueKey, cfi);
     }
     
     @Override
@@ -115,8 +113,8 @@ public class KeysIndex extends PerColumn
     @Override
     public void removeIndex(ByteBuffer columnName) throws IOException
     {        
-        indexedCfs.removeAllSSTables();
-        indexedCfs.unregisterMBean();     
+        indexCfs.removeAllSSTables();
+        indexCfs.unregisterMBean();
     }
 
     @Override
@@ -124,7 +122,7 @@ public class KeysIndex extends PerColumn
     {       
         try
         {
-            indexedCfs.forceBlockingFlush();
+            indexCfs.forceBlockingFlush();
         } 
         catch (ExecutionException e)
         {
@@ -139,13 +137,13 @@ public class KeysIndex extends PerColumn
     @Override
     public void unregisterMbean()
     {
-        indexedCfs.unregisterMBean();        
+        indexCfs.unregisterMBean();
     }
 
     @Override
     public ColumnFamilyStore getUnderlyingCfs()
     {
-       return indexedCfs;
+       return indexCfs;
     }
 
     @Override
@@ -157,13 +155,13 @@ public class KeysIndex extends PerColumn
     @Override
     public String getIndexName()
     {
-        return indexedCfs.columnFamily;
+        return indexCfs.columnFamily;
     }
 
     @Override
     public void renameIndex(String newCfName) throws IOException
     {
-        indexedCfs.renameSSTables(indexedCfs.columnFamily.replace(baseCfs.columnFamily, newCfName));
      
+        indexCfs.renameSSTables(indexCfs.columnFamily.replace(baseCfs.columnFamily, newCfName));
     }
 
     @Override



Mime
View raw message