cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1224998 - in /cassandra/trunk: ./ contrib/ doc/cql/ interface/thrift/gen-java/org/apache/cassandra/thrift/ src/avro/ src/java/org/apache/cassandra/cql/ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/db/index/ src/java/org/...
Date Tue, 27 Dec 2011 20:03:38 GMT
Author: jbellis
Date: Tue Dec 27 20:03:37 2011
New Revision: 1224998

URL: http://svn.apache.org/viewvc?rev=1224998&view=rev
Log:
merge from 1.0

Modified:
    cassandra/trunk/   (props changed)
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/contrib/   (props changed)
    cassandra/trunk/doc/cql/CQL.textile
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java 
 (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java   (props
changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
  (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
  (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
  (props changed)
    cassandra/trunk/src/avro/internode.genavro
    cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g
    cassandra/trunk/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/trunk/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
    cassandra/trunk/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
    cassandra/trunk/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java

Propchange: cassandra/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec 27 20:03:37 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1220925,1220927-1222440
 /cassandra/branches/cassandra-0.8.0:1125021-1130369
 /cassandra/branches/cassandra-0.8.1:1101014-1125018
-/cassandra/branches/cassandra-1.0:1167085-1222743
+/cassandra/branches/cassandra-1.0:1167085-1224997
 /cassandra/branches/cassandra-1.0.0:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/branches/cassandra-1.0.5:1208016
 /cassandra/tags/cassandra-0.7.0-rc3:1051699-1053689

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1224998&r1=1224997&r2=1224998&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Tue Dec 27 20:03:37 2011
@@ -45,11 +45,13 @@
  * Avoid creating empty and non cleaned writer during compaction (CASSANDRA-3616)
  * stop thrift service in shutdown hook so we can quiesce MessagingService
    (CASSANDRA-3335)
+ * (CQL) compaction_strategy_options and compression_parameters for
+   CREATE COLUMNFAMILY statement (CASSANDRA-3374)
 Merged from 0.8:
  * avoid logging (harmless) exception when GC takes < 1ms (CASSANDRA-3656)
  * prevent new nodes from thinking down nodes are up forever (CASSANDRA-3626)
  * Flush non-cfs backed secondary indexes (CASSANDRA-3659)
-
+ * Secondary Indexes should report memory consumption (CASSANDRA-3155)
 
 1.0.6
  * (CQL) fix cqlsh support for replicate_on_write (CASSANDRA-3596)

Propchange: cassandra/trunk/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec 27 20:03:37 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/contrib:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1220925,1220927-1222440
 /cassandra/branches/cassandra-0.8.0/contrib:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/contrib:1101014-1125018
-/cassandra/branches/cassandra-1.0/contrib:1167085-1222743
+/cassandra/branches/cassandra-1.0/contrib:1167085-1224997
 /cassandra/branches/cassandra-1.0.0/contrib:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/branches/cassandra-1.0.5/contrib:1208016
 /cassandra/tags/cassandra-0.7.0-rc3/contrib:1051699-1053689

Modified: cassandra/trunk/doc/cql/CQL.textile
URL: http://svn.apache.org/viewvc/cassandra/trunk/doc/cql/CQL.textile?rev=1224998&r1=1224997&r2=1224998&view=diff
==============================================================================
--- cassandra/trunk/doc/cql/CQL.textile (original)
+++ cassandra/trunk/doc/cql/CQL.textile Tue Dec 27 20:03:37 2011
@@ -488,9 +488,14 @@ bc(syntax). 
 <createColumnFamilyStatement> ::= "CREATE" "COLUMNFAMILY" <name>
                                     "(" <term> <storageType> "PRIMARY" "KEY"
                                         ( "," <term> <storageType> )* ")"
-                                   ( "WITH" <identifier> "=" <cfOptionVal>
-                                     ( "AND" <identifier> "=" <cfOptionVal> )*
)?
+                                   ( "WITH" <optionName> "=" <cfOptionVal>
+                                     ( "AND" <optionName> "=" <cfOptionVal> )*
)?
                                 ;
+<optionName> ::= <identifier>
+               | <optionName> ":" <identifier>
+               | <optionName> ":" <integer>
+               ;
+
 <cfOptionVal> ::= <storageType>
                 | <identifier>
                 | <stringLiteral>
@@ -544,6 +549,8 @@ A number of optional keyword arguments c
 |min_compaction_threshold|4|Minimum number of SSTables needed to start a minor compaction.|
 |max_compaction_threshold|32|Maximum number of SSTables allowed before a minor compaction
is forced.|
 |replicate_on_write|false| |
+|compaction_strategy_options|none|CompactionStrategy specific options such as "sstable_size_in_mb"
for LeveledCompactionStrategy and "min_sstable_size" for SizeTieredCompactionStrategy|
+|compression_parameters|none|Compression parameters such as "sstable_compressor" and "chunk_length_kb"|
 
 h2. CREATE INDEX
 

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec 27 20:03:37 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1220925,1220927-1222440
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1167085-1222743
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1167085-1224997
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/branches/cassandra-1.0.5/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1208016
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1051699-1053689

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec 27 20:03:37 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1220925,1220927-1222440
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1167085-1222743
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1167085-1224997
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/branches/cassandra-1.0.5/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1208016
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1051699-1053689

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec 27 20:03:37 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1220925,1220927-1222440
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1167085-1222743
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1167085-1224997
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/branches/cassandra-1.0.5/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1208016
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1051699-1053689

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec 27 20:03:37 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1220925,1220927-1222440
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1167085-1222743
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1167085-1224997
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/branches/cassandra-1.0.5/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1208016
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1051699-1053689

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec 27 20:03:37 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1220925,1220927-1222440
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1167085-1222743
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1167085-1224997
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/branches/cassandra-1.0.5/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1208016
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1051699-1053689

Modified: cassandra/trunk/src/avro/internode.genavro
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/avro/internode.genavro?rev=1224998&r1=1224997&r2=1224998&view=diff
==============================================================================
--- cassandra/trunk/src/avro/internode.genavro (original)
+++ cassandra/trunk/src/avro/internode.genavro Tue Dec 27 20:03:37 2011
@@ -65,7 +65,7 @@ protocol InterNode {
         union { null, string } compaction_strategy = null;
         union { null, map<string> } compaction_strategy_options = null;
         union { null, map<string> } compression_options = null;
-        union { double, null } bloom_filter_fp_chance;
+        union { null, double } bloom_filter_fp_chance = null;
     }
 
     @aliases(["org.apache.cassandra.config.avro.KsDef"])

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g?rev=1224998&r1=1224997&r2=1224998&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g Tue Dec 27 20:03:37 2011
@@ -379,8 +379,8 @@ createKeyspaceStatement returns [CreateK
 createColumnFamilyStatement returns [CreateColumnFamilyStatement expr]
     : K_CREATE K_COLUMNFAMILY name=( IDENT | STRING_LITERAL | INTEGER ) { $expr = new CreateColumnFamilyStatement($name.text);
}
       ( '(' createCfamColumns[expr] ( ',' createCfamColumns[expr] )* ')' )?
-      ( K_WITH prop1=IDENT '=' arg1=createCfamKeywordArgument { $expr.addProperty($prop1.text,
$arg1.arg); }
-          ( K_AND propN=IDENT '=' argN=createCfamKeywordArgument { $expr.addProperty($propN.text,
$argN.arg); } )*
+      ( K_WITH prop1=(COMPIDENT | IDENT) '=' arg1=createCfamKeywordArgument { $expr.addProperty($prop1.text,
$arg1.arg); }
+          ( K_AND propN=(COMPIDENT | IDENT) '=' argN=createCfamKeywordArgument { $expr.addProperty($propN.text,
$argN.arg); } )*
       )?
       endStmnt
     ;

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java?rev=1224998&r1=1224997&r2=1224998&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java Tue
Dec 27 20:03:37 2011
@@ -42,6 +42,7 @@ import org.apache.cassandra.db.marshal.T
 import org.apache.cassandra.thrift.InvalidRequestException;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.io.compress.CompressionParameters;
 
 /** A <code>CREATE COLUMNFAMILY</code> parsed from a CQL query statement. */
 public class CreateColumnFamilyStatement
@@ -57,11 +58,16 @@ public class CreateColumnFamilyStatement
     private static final String KW_MAXCOMPACTIONTHRESHOLD = "max_compaction_threshold";
     private static final String KW_REPLICATEONWRITE = "replicate_on_write";
 
+    private static final String KW_COMPACTION_STRATEGY_CLASS = "compaction_strategy_class";
+    
     // Maps CQL short names to the respective Cassandra comparator/validator class names
     public  static final Map<String, String> comparators = new HashMap<String, String>();
     private static final Set<String> keywords = new HashSet<String>();
     private static final Set<String> obsoleteKeywords = new HashSet<String>();
-    
+
+    private static final String COMPACTION_OPTIONS_PREFIX = "compaction_strategy_options";
+    private static final String COMPRESSION_PARAMETERS_PREFIX = "compression_parameters";
+
     static
     {
         comparators.put("ascii", "AsciiType");
@@ -87,6 +93,7 @@ public class CreateColumnFamilyStatement
         keywords.add(KW_MINCOMPACTIONTHRESHOLD);
         keywords.add(KW_MAXCOMPACTIONTHRESHOLD);
         keywords.add(KW_REPLICATEONWRITE);
+        keywords.add(KW_COMPACTION_STRATEGY_CLASS);
 
         obsoleteKeywords.add("row_cache_size");
         obsoleteKeywords.add("key_cache_size");
@@ -103,6 +110,8 @@ public class CreateColumnFamilyStatement
     private final Map<String, String> properties = new HashMap<String, String>();
     private List<String> keyValidator = new ArrayList<String>();
     private ByteBuffer keyAlias = null;
+    private final Map<String, String> compactionStrategyOptions = new HashMap<String,
String>();
+    private final Map<String, String> compressionParameters = new HashMap<String,
String>();
 
     public CreateColumnFamilyStatement(String name)
     {
@@ -112,6 +121,34 @@ public class CreateColumnFamilyStatement
     /** Perform validation of parsed params */
     private void validate(List<String> variables) throws InvalidRequestException
     {
+        // we need to remove parent:key = value pairs from the main properties
+        Set<String> propsToRemove = new HashSet<String>();
+
+        // check if we have compaction/compression options
+        for (String property : properties.keySet())
+        {
+            if (!property.contains(":"))
+                continue;
+
+            String key = property.split(":")[1];
+            String val = properties.get(property);
+
+            if (property.startsWith(COMPACTION_OPTIONS_PREFIX))
+            {
+                compactionStrategyOptions.put(key, val);
+                propsToRemove.add(property);
+            }
+
+            if (property.startsWith(COMPRESSION_PARAMETERS_PREFIX))
+            {
+                compressionParameters.put(key, val);
+                propsToRemove.add(property);
+            }
+        }
+
+        for (String property : propsToRemove)
+            properties.remove(property);
+
         // Column family name
         if (!name.matches("\\w+"))
             throw new InvalidRequestException(String.format("\"%s\" is not a valid column
family name", name));
@@ -292,6 +329,8 @@ public class CreateColumnFamilyStatement
                    .columnMetadata(getColumns(comparator))
                    .keyValidator(TypeParser.parse(comparators.get(getKeyType())))
                    .keyAlias(keyAlias)
+                   .compactionStrategyOptions(compactionStrategyOptions)
+                   .compressionParameters(CompressionParameters.create(compressionParameters))
                    .validate();
         }
         catch (ConfigurationException e)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1224998&r1=1224997&r2=1224998&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Tue Dec 27 20:03:37
2011
@@ -977,10 +977,7 @@ public class ColumnFamilyStore implement
 
     public long getTotalMemtableLiveSize()
     {
-        long total = 0;
-        for (ColumnFamilyStore cfs : concatWithIndexes())
-            total += cfs.getMemtableThreadSafe().getLiveSize();
-        return total;
+        return getMemtableDataSize() + indexManager.getTotalLiveSize();
     }
 
     public int getMemtableSwitchCount()

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/index/SecondaryIndex.java?rev=1224998&r1=1224997&r2=1224998&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/index/SecondaryIndex.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/index/SecondaryIndex.java Tue Dec 27
20:03:37 2011
@@ -112,6 +112,11 @@ public abstract class SecondaryIndex
     public abstract void forceBlockingFlush() throws IOException;
 
     /**
+     * Get current amount of memory this index is consuming (in bytes)
+     */
+    public abstract long getLiveSize();
+    
+    /**
      * Allow access to the underlying column family store if there is one
      * @return the underlying column family store or null
      */

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java?rev=1224998&r1=1224997&r2=1224998&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java Tue
Dec 27 20:03:37 2011
@@ -328,6 +328,27 @@ public class SecondaryIndexManager
         return indexList.keySet();
     }
     
+    /**
+     * @return total current ram size of all indexes
+     */
+    public long getTotalLiveSize()
+    {
+        long total = 0;
+        
+        // we use identity map because per row indexes use same instance
+        // across many columns
+        IdentityHashMap<SecondaryIndex, Object> indexList = new IdentityHashMap<SecondaryIndex,
Object>();
+
+        for (Map.Entry<ByteBuffer, SecondaryIndex> entry : indexesByColumn.entrySet())
+        {
+            SecondaryIndex index = entry.getValue();
+            
+            if (indexList.put(index, index) == null)
+                total += index.getLiveSize();
+        }
+        
+        return total;
+    }
     
     /**
      * Removes obsolete index entries and creates new ones for the given row key

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java?rev=1224998&r1=1224997&r2=1224998&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java Tue Dec 27
20:03:37 2011
@@ -152,4 +152,9 @@ public class KeysIndex extends PerColumn
     {
         // no options used
     }
+
+    public long getLiveSize()
+    {
+        return indexCfs.getMemtableDataSize();
+    }
 }



Mime
View raw message