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));
}
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 CommitLogTest method testDontDeleteIfDirty.
@Test
public void testDontDeleteIfDirty() throws Exception {
CommitLog.instance.resetUnsafe();
// Roughly 32 MB mutation
RowMutation rm = new RowMutation("Keyspace1", bytes("k"));
rm.add(new QueryPath("Standard1", null, bytes("c1")), ByteBuffer.allocate(32 * 1024 * 1024), 0);
// Adding it 5 times
CommitLog.instance.add(rm);
CommitLog.instance.add(rm);
CommitLog.instance.add(rm);
CommitLog.instance.add(rm);
CommitLog.instance.add(rm);
// Adding new mutation on another CF
RowMutation rm2 = new RowMutation("Keyspace1", bytes("k"));
rm2.add(new QueryPath("Standard2", null, bytes("c1")), ByteBuffer.allocate(4), 0);
CommitLog.instance.add(rm2);
assert CommitLog.instance.activeSegments() == 2 : "Expecting 2 segments, got " + CommitLog.instance.activeSegments();
int cfid2 = rm2.getColumnFamilyIds().iterator().next();
CommitLog.instance.discardCompletedSegments(cfid2, CommitLog.instance.getContext());
// Assert we still have both our segment
assert CommitLog.instance.activeSegments() == 2 : "Expecting 2 segments, got " + CommitLog.instance.activeSegments();
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class LazilyCompactedRowTest method testOneRowManyColumns.
@Test
public void testOneRowManyColumns() throws IOException, ExecutionException, InterruptedException, NoSuchAlgorithmException {
CompactionManager.instance.disableAutoCompaction();
Table table = Table.open("Keyspace1");
ColumnFamilyStore cfs = table.getColumnFamilyStore("Standard1");
ByteBuffer key = ByteBuffer.wrap("k".getBytes());
RowMutation rm = new RowMutation("Keyspace1", key);
for (int i = 0; i < 1000; i++) rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes(i)), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
rm.apply();
DataOutputBuffer out = new DataOutputBuffer();
RowMutation.serializer().serialize(rm, out, MessagingService.version_);
assert out.getLength() > DatabaseDescriptor.getColumnIndexSize();
cfs.forceBlockingFlush();
assertBytes(cfs, Integer.MAX_VALUE);
assertDigest(cfs, Integer.MAX_VALUE);
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class LazilyCompactedRowTest method testManyRows.
@Test
public void testManyRows() throws IOException, ExecutionException, InterruptedException, NoSuchAlgorithmException {
CompactionManager.instance.disableAutoCompaction();
Table table = Table.open("Keyspace1");
ColumnFamilyStore cfs = table.getColumnFamilyStore("Standard1");
final int ROWS_PER_SSTABLE = 10;
for (int j = 0; j < (DatabaseDescriptor.getIndexInterval() * 3) / ROWS_PER_SSTABLE; j++) {
for (int i = 0; i < ROWS_PER_SSTABLE; i++) {
ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(i % 2));
RowMutation rm = new RowMutation("Keyspace1", key);
rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes(String.valueOf(i / 2))), ByteBufferUtil.EMPTY_BYTE_BUFFER, j * ROWS_PER_SSTABLE + i);
rm.apply();
}
cfs.forceBlockingFlush();
}
assertBytes(cfs, Integer.MAX_VALUE);
assertDigest(cfs, Integer.MAX_VALUE);
}
Aggregations