use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class RemoveColumnFamilyWithFlush2Test method testRemoveColumnFamilyWithFlush2.
@Test
public void testRemoveColumnFamilyWithFlush2() throws IOException, ExecutionException, InterruptedException {
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
RowMutation rm;
DecoratedKey dk = Util.dk("key1");
// add data
rm = new RowMutation("Keyspace1", dk.key);
rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column1")), ByteBufferUtil.bytes("asdf"), 0);
rm.apply();
// remove
rm = new RowMutation("Keyspace1", dk.key);
rm.delete(new QueryPath("Standard1"), 1);
rm.apply();
store.forceBlockingFlush();
ColumnFamily retrieved = store.getColumnFamily(QueryFilter.getIdentityFilter(dk, new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column1"))));
assert retrieved.isMarkedForDelete();
assertNull(retrieved.getColumn(ByteBufferUtil.bytes("Column1")));
assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class RemoveSubColumnTest method testRemoveSubColumn.
@Test
public void testRemoveSubColumn() throws IOException, ExecutionException, InterruptedException {
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Super1");
RowMutation rm;
DecoratedKey dk = Util.dk("key1");
// add data
rm = new RowMutation("Keyspace1", dk.key);
Util.addMutation(rm, "Super1", "SC1", 1, "asdf", 0);
rm.apply();
store.forceBlockingFlush();
// remove
rm = new RowMutation("Keyspace1", dk.key);
rm.delete(new QueryPath("Super1", ByteBufferUtil.bytes("SC1"), getBytes(1L)), 1);
rm.apply();
ColumnFamily retrieved = store.getColumnFamily(QueryFilter.getIdentityFilter(dk, new QueryPath("Super1", ByteBufferUtil.bytes("SC1"))));
assert retrieved.getColumn(ByteBufferUtil.bytes("SC1")).getSubColumn(getBytes(1L)).isMarkedForDelete();
assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class RowCacheTest method testRowCache.
@Test
public void testRowCache() throws Exception {
CompactionManager.instance.disableAutoCompaction();
Table table = Table.open(KEYSPACE);
ColumnFamilyStore cachedStore = table.getColumnFamilyStore(COLUMN_FAMILY);
// empty the row cache
CacheService.instance.invalidateRowCache();
// set global row cache size to 1 MB
CacheService.instance.setRowCacheCapacityInMB(1);
// inserting 100 rows into both column families
insertData(KEYSPACE, COLUMN_FAMILY, 0, 100);
// 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, null, ByteBufferUtil.bytes("col" + i));
cachedStore.getColumnFamily(key, path, ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, 1);
assert CacheService.instance.rowCache.size() == i + 1;
// current key should be stored in the cache
assert cachedStore.getRawCachedRow(key) != null;
// 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));
}
// insert 10 more keys
insertData(KEYSPACE, COLUMN_FAMILY, 100, 10);
for (int i = 100; i < 110; i++) {
DecoratedKey key = Util.dk("key" + i);
QueryPath path = new QueryPath(COLUMN_FAMILY, null, ByteBufferUtil.bytes("col" + i));
cachedStore.getColumnFamily(key, path, ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, 1);
// cache should be populated with the latest rows read (old ones should be popped)
assert cachedStore.getRawCachedRow(key) != null;
// 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));
}
// clear 100 rows from the cache
int keysLeft = 109;
for (int i = 109; i >= 10; i--) {
cachedStore.invalidateCachedRow(Util.dk("key" + i));
assert CacheService.instance.rowCache.size() == keysLeft;
keysLeft--;
}
CacheService.instance.setRowCacheCapacityInMB(0);
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class RemoveColumnFamilyWithFlush1Test method testRemoveColumnFamilyWithFlush1.
@Test
public void testRemoveColumnFamilyWithFlush1() throws IOException, ExecutionException, InterruptedException {
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
RowMutation rm;
DecoratedKey dk = Util.dk("key1");
// add data
rm = new RowMutation("Keyspace1", dk.key);
rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column1")), ByteBufferUtil.bytes("asdf"), 0);
rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column2")), ByteBufferUtil.bytes("asdf"), 0);
rm.apply();
store.forceBlockingFlush();
// remove
rm = new RowMutation("Keyspace1", dk.key);
rm.delete(new QueryPath("Standard1"), 1);
rm.apply();
ColumnFamily retrieved = store.getColumnFamily(QueryFilter.getIdentityFilter(dk, new QueryPath("Standard1")));
assert retrieved.isMarkedForDelete();
assertNull(retrieved.getColumn(ByteBufferUtil.bytes("Column1")));
assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class RemoveColumnTest method testRemoveColumn.
@Test
public void testRemoveColumn() throws IOException, ExecutionException, InterruptedException {
Table table = Table.open("Keyspace1");
ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
RowMutation rm;
DecoratedKey dk = Util.dk("key1");
// add data
rm = new RowMutation("Keyspace1", dk.key);
rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column1")), ByteBufferUtil.bytes("asdf"), 0);
rm.apply();
store.forceBlockingFlush();
// remove
rm = new RowMutation("Keyspace1", dk.key);
rm.delete(new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column1")), 1);
rm.apply();
ColumnFamily retrieved = store.getColumnFamily(QueryFilter.getNamesFilter(dk, new QueryPath("Standard1"), ByteBufferUtil.bytes("Column1")));
assert retrieved.getColumn(ByteBufferUtil.bytes("Column1")).isMarkedForDelete();
assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
assertNull(Util.cloneAndRemoveDeleted(store.getColumnFamily(QueryFilter.getIdentityFilter(dk, new QueryPath("Standard1"))), Integer.MAX_VALUE));
}
Aggregations