Merge branch 'cassandra-2.0' into cassandra-2.1

Conflicts:
	CHANGES.txt
	test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
This commit is contained in:
Marcus Eriksson 2014-12-24 14:00:05 +01:00
commit b53fefa731
3 changed files with 35 additions and 1 deletions

View File

@ -42,6 +42,7 @@
* Log failed host when preparing incremental repair (CASSANDRA-8228)
* Force config client mode in CQLSSTableWriter (CASSANDRA-8281)
Merged from 2.0:
* 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)

View File

@ -1395,7 +1395,10 @@ public class SSTableReader extends SSTable
RowIndexEntry cachedEntry = keyCache.get(unifiedKey);
keyCacheRequest.incrementAndGet();
if (cachedEntry != null)
{
keyCacheHit.incrementAndGet();
bloomFilterTracker.addTruePositive();
}
return cachedEntry;
}
else

View File

@ -68,7 +68,6 @@ import org.apache.cassandra.service.CacheService;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.utils.Pair;
import static org.apache.cassandra.Util.cellname;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -264,6 +263,37 @@ public class SSTableReaderTest extends SchemaLoader
// check if opening and querying works
assertIndexQueryWorks(store);
}
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));
Mutation rm = new Mutation("Keyspace1", key);
rm.add("Standard2", cellname("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 testOpeningSSTable() throws Exception