use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class RowIterationTest method testRowIterationDeletionTime.
@Test
public void testRowIterationDeletionTime() throws IOException, ExecutionException, InterruptedException {
Table table = Table.open(TABLE1);
String CF_NAME = "Standard3";
ColumnFamilyStore store = table.getColumnFamilyStore(CF_NAME);
DecoratedKey key = Util.dk("key");
// Delete row in first sstable
RowMutation rm = new RowMutation(TABLE1, key.key);
rm.delete(new QueryPath(CF_NAME, null, null), 0);
rm.add(new QueryPath(CF_NAME, null, ByteBufferUtil.bytes("c")), ByteBufferUtil.bytes("values"), 0L);
int tstamp1 = rm.getColumnFamilies().iterator().next().getLocalDeletionTime();
rm.apply();
store.forceBlockingFlush();
// Delete row in second sstable with higher timestamp
rm = new RowMutation(TABLE1, key.key);
rm.delete(new QueryPath(CF_NAME, null, null), 1);
rm.add(new QueryPath(CF_NAME, null, ByteBufferUtil.bytes("c")), ByteBufferUtil.bytes("values"), 1L);
int tstamp2 = rm.getColumnFamilies().iterator().next().getLocalDeletionTime();
rm.apply();
store.forceBlockingFlush();
ColumnFamily cf = Util.getRangeSlice(store).iterator().next().cf;
assert cf.getMarkedForDeleteAt() == 1L;
assert cf.getLocalDeletionTime() == tstamp2;
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class TimeSortTest method testMixedSources.
@Test
public void testMixedSources() throws IOException, ExecutionException, InterruptedException {
Table table = Table.open("Keyspace1");
ColumnFamilyStore cfStore = table.getColumnFamilyStore("StandardLong1");
RowMutation rm;
DecoratedKey key = Util.dk("key0");
rm = new RowMutation("Keyspace1", key.key);
rm.add(new QueryPath("StandardLong1", null, getBytes(100)), ByteBufferUtil.bytes("a"), 100);
rm.apply();
cfStore.forceBlockingFlush();
rm = new RowMutation("Keyspace1", key.key);
rm.add(new QueryPath("StandardLong1", null, getBytes(0)), ByteBufferUtil.bytes("b"), 0);
rm.apply();
ColumnFamily cf = cfStore.getColumnFamily(key, new QueryPath("StandardLong1"), getBytes(10), ByteBufferUtil.EMPTY_BYTE_BUFFER, false, 1000);
Collection<IColumn> columns = cf.getSortedColumns();
assert columns.size() == 1;
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class CompactionsTest method testStandardColumnCompactions.
@Test
public void testStandardColumnCompactions() throws IOException, ExecutionException, InterruptedException {
// this test does enough rows to force multiple block indexes to be used
Table table = Table.open(TABLE1);
ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
final int ROWS_PER_SSTABLE = 10;
final int SSTABLES = DatabaseDescriptor.getIndexInterval() * 3 / ROWS_PER_SSTABLE;
// disable compaction while flushing
store.disableAutoCompaction();
long maxTimestampExpected = Long.MIN_VALUE;
Set<DecoratedKey> inserted = new HashSet<DecoratedKey>();
for (int j = 0; j < SSTABLES; j++) {
for (int i = 0; i < ROWS_PER_SSTABLE; i++) {
DecoratedKey key = Util.dk(String.valueOf(i % 2));
RowMutation rm = new RowMutation(TABLE1, key.key);
long timestamp = j * ROWS_PER_SSTABLE + i;
rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes(String.valueOf(i / 2))), ByteBufferUtil.EMPTY_BYTE_BUFFER, timestamp);
maxTimestampExpected = Math.max(timestamp, maxTimestampExpected);
rm.apply();
inserted.add(key);
}
store.forceBlockingFlush();
assertMaxTimestamp(store, maxTimestampExpected);
assertEquals(inserted.toString(), inserted.size(), Util.getRangeSlice(store).size());
}
forceCompactions(store);
assertEquals(inserted.size(), Util.getRangeSlice(store).size());
// make sure max timestamp of compacted sstables is recorded properly after compaction.
assertMaxTimestamp(store, maxTimestampExpected);
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class CompactionsTest method testSuperColumnCompactions.
@Test
public void testSuperColumnCompactions() throws IOException, ExecutionException, InterruptedException {
Table table = Table.open(TABLE1);
ColumnFamilyStore store = table.getColumnFamilyStore("Super1");
final int ROWS_PER_SSTABLE = 10;
final int SSTABLES = DatabaseDescriptor.getIndexInterval() * 3 / ROWS_PER_SSTABLE;
// disable compaction while flushing
store.disableAutoCompaction();
long maxTimestampExpected = Long.MIN_VALUE;
Set<DecoratedKey> inserted = new HashSet<DecoratedKey>();
ByteBuffer superColumn = ByteBufferUtil.bytes("TestSuperColumn");
for (int j = 0; j < SSTABLES; j++) {
for (int i = 0; i < ROWS_PER_SSTABLE; i++) {
DecoratedKey key = Util.dk(String.valueOf(i % 2));
RowMutation rm = new RowMutation(TABLE1, key.key);
long timestamp = j * ROWS_PER_SSTABLE + i;
rm.add(new QueryPath("Super1", superColumn, ByteBufferUtil.bytes(String.valueOf(i / 2))), ByteBufferUtil.EMPTY_BYTE_BUFFER, timestamp);
maxTimestampExpected = Math.max(timestamp, maxTimestampExpected);
rm.apply();
inserted.add(key);
}
store.forceBlockingFlush();
assertMaxTimestamp(store, maxTimestampExpected);
assertEquals(inserted.toString(), inserted.size(), Util.getRangeSlice(store, superColumn).size());
}
forceCompactions(store);
assertEquals(inserted.size(), Util.getRangeSlice(store, superColumn).size());
// make sure max timestamp of compacted sstables is recorded properly after compaction.
assertMaxTimestamp(store, maxTimestampExpected);
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class KeyCollisionTest method insert.
private void insert(String key) throws IOException {
RowMutation rm;
rm = new RowMutation(KEYSPACE, ByteBufferUtil.bytes(key));
rm.add(new QueryPath(CF, null, ByteBufferUtil.bytes("column")), ByteBufferUtil.bytes("asdf"), 0);
rm.apply();
}
Aggregations