mirror of https://github.com/apache/cassandra
Increase bloom filter true positive count on key cache hit
Patch by marcuse; reviewed by thobbs for CASSANDRA-8525
This commit is contained in:
parent
5f54285e9e
commit
f981bd5969
|
|
@ -1,4 +1,5 @@
|
|||
2.0.12:
|
||||
* Increase bf true positive count on key cache hit (CASSANDRA-8525)
|
||||
* Move MeteredFlusher to its own thread (CASSANDRA-8485)
|
||||
* Fix non-distinct results in DISTNCT queries on static columns when
|
||||
paging is enabled (CASSANDRA-8087)
|
||||
|
|
|
|||
|
|
@ -887,7 +887,10 @@ public class SSTableReader extends SSTable implements Closeable
|
|||
RowIndexEntry cachedEntry = keyCache.get(unifiedKey);
|
||||
keyCacheRequest.incrementAndGet();
|
||||
if (cachedEntry != null)
|
||||
{
|
||||
keyCacheHit.incrementAndGet();
|
||||
bloomFilterTracker.addTruePositive();
|
||||
}
|
||||
return cachedEntry;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ import org.apache.cassandra.thrift.IndexExpression;
|
|||
import org.apache.cassandra.thrift.IndexOperator;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
|
|
@ -203,6 +204,39 @@ public class SSTableReaderTest extends SchemaLoader
|
|||
assert p.right == p7;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPositionsKeyCacheStats() throws IOException, ExecutionException, InterruptedException
|
||||
{
|
||||
Keyspace keyspace = Keyspace.open("Keyspace1");
|
||||
ColumnFamilyStore store = keyspace.getColumnFamilyStore("Standard2");
|
||||
CacheService.instance.keyCache.setCapacity(1000);
|
||||
|
||||
// insert data and compact to a single sstable
|
||||
CompactionManager.instance.disableAutoCompaction();
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(j));
|
||||
RowMutation rm = new RowMutation("Keyspace1", key);
|
||||
rm.add("Standard2", ByteBufferUtil.bytes("0"), ByteBufferUtil.EMPTY_BYTE_BUFFER, j);
|
||||
rm.apply();
|
||||
}
|
||||
store.forceBlockingFlush();
|
||||
CompactionManager.instance.performMaximal(store);
|
||||
|
||||
SSTableReader sstable = store.getSSTables().iterator().next();
|
||||
sstable.getPosition(k(2), SSTableReader.Operator.EQ);
|
||||
assertEquals(0, sstable.getKeyCacheHit());
|
||||
assertEquals(1, sstable.getBloomFilterTruePositiveCount());
|
||||
sstable.getPosition(k(2), SSTableReader.Operator.EQ);
|
||||
assertEquals(1, sstable.getKeyCacheHit());
|
||||
assertEquals(2, sstable.getBloomFilterTruePositiveCount());
|
||||
sstable.getPosition(k(15), SSTableReader.Operator.EQ);
|
||||
assertEquals(1, sstable.getKeyCacheHit());
|
||||
assertEquals(2, sstable.getBloomFilterTruePositiveCount());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPersistentStatisticsWithSecondaryIndex() throws IOException, ExecutionException, InterruptedException
|
||||
{
|
||||
|
|
@ -254,7 +288,7 @@ public class SSTableReaderTest extends SchemaLoader
|
|||
|
||||
// test to see if sstable can be opened as expected
|
||||
SSTableReader target = SSTableReader.open(desc);
|
||||
Assert.assertEquals(target.getKeySampleSize(), 1);
|
||||
assertEquals(target.getKeySampleSize(), 1);
|
||||
Assert.assertArrayEquals(ByteBufferUtil.getArray(firstKey.key), target.getKeySample(0));
|
||||
assert target.first.equals(firstKey);
|
||||
assert target.last.equals(lastKey);
|
||||
|
|
|
|||
Loading…
Reference in New Issue