// now reading rows one by one and checking if row change grows
for (int i = 0; i < 100; i++)
{
DecoratedKey key = Util.dk("key" + i);
QueryPath path = new QueryPath(COLUMN_FAMILY_WITH_CACHE, null, ByteBufferUtil.bytes("col" + i));
cachedStore.getColumnFamily(key, path, ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, 1);
assert cachedStore.getRowCacheSize() == i + 1;
assert cachedStore.getRawCachedRow(key) != null; // current key should be stored in the cache
// checking if column is read correctly after cache
ColumnFamily cf = cachedStore.getColumnFamily(key, path, ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, 1);
Collection<IColumn> columns = cf.getSortedColumns();
IColumn column = columns.iterator().next();
assert columns.size() == 1;
assert column.name().equals(ByteBufferUtil.bytes("col" + i));
assert column.value().equals(ByteBufferUtil.bytes("val" + i));
path = new QueryPath(COLUMN_FAMILY_WITHOUT_CACHE, null, ByteBufferUtil.bytes("col" + i));
// row cache should not get populated for the second store
noCacheStore.getColumnFamily(key, path, ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, 1);
assert noCacheStore.getRowCacheSize() == 0;
}
// insert 10 more keys and check that row cache is still at store.getRowCacheCapacity()
insertData(KEYSPACE, COLUMN_FAMILY_WITH_CACHE, 100, 10);
for (int i = 100; i < 110; i++)
{
DecoratedKey key = Util.dk("key" + i);
QueryPath path = new QueryPath(COLUMN_FAMILY_WITH_CACHE, null, ByteBufferUtil.bytes("col" + i));
cachedStore.getColumnFamily(key, path, ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, 1);
assert cachedStore.getRowCacheSize() == cachedStore.getRowCacheCapacity();
assert cachedStore.getRawCachedRow(key) != null; // cache should be populated with the latest rows read (old ones should be popped)