mirror of https://github.com/apache/cassandra
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 git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@900435 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
72a9a4eaae
commit
27101e9626
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public class DatabaseDescriptor
|
|||
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 @@ public class DatabaseDescriptor
|
|||
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 class DatabaseDescriptor
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,11 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -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"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue