cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r900435 - in /incubator/cassandra/trunk: conf/storage-conf.xml src/java/org/apache/cassandra/config/DatabaseDescriptor.java src/java/org/apache/cassandra/db/ColumnFamilyStore.java test/conf/storage-conf.xml
Date Mon, 18 Jan 2010 15:51:26 GMT
Author: jbellis
Date: Mon Jan 18 15:51:26 2010
New Revision: 900435

URL: http://svn.apache.org/viewvc?rev=900435&view=rev
Log:
change RowsCachedFraction option to RowsCached, specified either as an absolute number or
as a percentage of rows in the CF
patch by jbellis; reviewed by goffinet for CASSANDRA-688

Modified:
    incubator/cassandra/trunk/conf/storage-conf.xml
    incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    incubator/cassandra/trunk/test/conf/storage-conf.xml

Modified: incubator/cassandra/trunk/conf/storage-conf.xml
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/conf/storage-conf.xml?rev=900435&r1=900434&r2=900435&view=diff
==============================================================================
--- incubator/cassandra/trunk/conf/storage-conf.xml (original)
+++ incubator/cassandra/trunk/conf/storage-conf.xml Mon Jan 18 15:51:26 2010
@@ -91,15 +91,16 @@
        ~ index. Consider increasing this if you have fewer, wider rows.
        ~ Set to 0 to disable entirely.
        ~
-       ~ The optional RowsCachedFraction attribute specifies
-       ~ The fraction of rows per sstable whose entire contents we cache in
-       ~ memory.  Do not use this on ColumnFamilies with large rows, or
+       ~ The optional RowsCached attribute specifies the number of rows
+       ~ whose entire contents we cache in memory, either as a fixed number
+       ~ of rows or as a percent of rows in the ColumnFamily.  
+       ~ Do not use this on ColumnFamilies with large rows, or
        ~ ColumnFamilies with high write:read ratios.  As with key caching,
        ~ valid values are from 0 to 1.  The default 0 disables it entirely.
       -->
       <ColumnFamily CompareWith="BytesType" 
                     Name="Standard1" 
-                    RowsCachedFraction="0.1"
+                    RowsCached="10%"
                     KeysCachedFraction="0"/>
       <ColumnFamily CompareWith="UTF8Type" Name="Standard2"/>
       <ColumnFamily CompareWith="TimeUUIDType" Name="StandardByUUID1"/>
@@ -107,6 +108,8 @@
                     CompareWith="UTF8Type"
                     CompareSubcolumnsWith="UTF8Type"
                     Name="Super1"
+                    RowsCached="1000"
+                    KeysCachedFraction="0"
                     Comment="A column family with supercolumns, whose column and subcolumn
names are UTF8 strings"/>
     </Keyspace>
   </Keyspaces>

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=900435&r1=900434&r2=900435&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Mon Jan 18 15:51:26 2010
@@ -87,7 +87,7 @@
     private static int bmtThreshold_ = 256;
 
     private static Map<Pair<String, String>, Double> tableKeysCachedFractions_
= new HashMap<Pair<String, String>, Double>();
-    private static Map<Pair<String, String>, Double> tableRowsCachedFractions_
= new HashMap<Pair<String, String>, Double>();
+    private static Map<Pair<String, String>, Double> tableRowCacheSizes = new
HashMap<Pair<String, String>, Double>();
 
     /*
      * A map from table names to the set of column families for the table and the
@@ -523,9 +523,16 @@
                         tableKeysCachedFractions_.put(Pair.create(tName, cfName), Double.valueOf(value));
                     }
                     
-                    if ((value = XMLUtils.getAttributeValue(columnFamily, "RowsCachedFraction"))
!= null)
+                    if ((value = XMLUtils.getAttributeValue(columnFamily, "RowsCached"))
!= null)
                     {
-                        tableRowsCachedFractions_.put(Pair.create(tName, cfName), Double.valueOf(value));
+                        if (value.endsWith("%"))
+                        {
+                            tableRowCacheSizes.put(Pair.create(tName, cfName), Double.valueOf(value.substring(0,
value.length() - 1)) / 100);
+                        }
+                        else
+                        {
+                            tableRowCacheSizes.put(Pair.create(tName, cfName), Double.valueOf(value));
+                        }
                     }
 
                     // Parse out user-specified logical names for the various dimensions
@@ -964,7 +971,7 @@
 
     public static double getRowsCachedFraction(String tableName, String columnFamilyName)
     {
-        Double v = tableRowsCachedFractions_.get(Pair.create(tableName, columnFamilyName));
+        Double v = tableRowCacheSizes.get(Pair.create(tableName, columnFamilyName));
         return v == null ? 0 : v;
     }
 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=900435&r1=900434&r2=900435&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Mon
Jan 18 15:51:26 2010
@@ -191,7 +191,11 @@
         double v = DatabaseDescriptor.getRowsCachedFraction(table, columnFamilyName);
         if (v > 0)
         {
-            int cacheSize = Math.max(1, (int)(v * SSTableReader.estimatedKeys(columnFamilyName)));
+            int cacheSize;
+            if (v < 1)
+                cacheSize = Math.max(1, (int)(v * SSTableReader.estimatedKeys(columnFamilyName)));
+            else
+                cacheSize = (int)v;
             if (logger_.isDebugEnabled())
                 logger_.debug("enabling row cache for " + columnFamilyName + " with size
" + cacheSize);
             rowCache = new JMXInstrumentedCache<String, ColumnFamily>(table, columnFamilyName
+ "RowCache", cacheSize);

Modified: incubator/cassandra/trunk/test/conf/storage-conf.xml
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/conf/storage-conf.xml?rev=900435&r1=900434&r2=900435&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/conf/storage-conf.xml (original)
+++ incubator/cassandra/trunk/test/conf/storage-conf.xml Mon Jan 18 15:51:26 2010
@@ -44,11 +44,11 @@
    <MemtableOperationsInMillions>0.00002</MemtableOperationsInMillions> <!--
20 -->
    <Keyspaces>
      <Keyspace Name = "Keyspace1">
-       <ColumnFamily Name="Standard1" RowsCachedFraction="0.1" KeysCachedFraction="0"/>
+       <ColumnFamily Name="Standard1" RowsCached="10%" KeysCachedFraction="0"/>
        <ColumnFamily Name="Standard2"/>
        <ColumnFamily CompareWith="LongType" Name="StandardLong1"/>
        <ColumnFamily CompareWith="LongType" Name="StandardLong2"/>
-       <ColumnFamily ColumnType="Super" CompareSubcolumnsWith="LongType" Name="Super1"
RowsCachedFraction="0.1" KeysCachedFraction="0"/>
+       <ColumnFamily ColumnType="Super" CompareSubcolumnsWith="LongType" Name="Super1"
RowsCached="1000" KeysCachedFraction="0"/>
        <ColumnFamily ColumnType="Super" CompareSubcolumnsWith="LongType" Name="Super2"/>
        <ColumnFamily ColumnType="Super" CompareSubcolumnsWith="LongType" Name="Super3"/>
        <ColumnFamily ColumnType="Super" CompareSubcolumnsWith="UTF8Type" Name="Super4"/>



Mime
View raw message