use of org.apache.cassandra.io.sstable.ISSTableScanner in project cassandra by apache.
the class TTLExpiryTest method testNoExpire.
@Test
public void testNoExpire() throws InterruptedException, IOException {
ColumnFamilyStore cfs = Keyspace.open(KEYSPACE1).getColumnFamilyStore("Standard1");
cfs.truncateBlocking();
cfs.disableAutoCompaction();
MigrationManager.announceTableUpdate(cfs.metadata().unbuild().gcGraceSeconds(0).build(), true);
long timestamp = System.currentTimeMillis();
String key = "ttl";
new RowUpdateBuilder(cfs.metadata(), timestamp, 1, key).add("col", ByteBufferUtil.EMPTY_BYTE_BUFFER).add("col7", ByteBufferUtil.EMPTY_BYTE_BUFFER).build().applyUnsafe();
cfs.forceBlockingFlush();
new RowUpdateBuilder(cfs.metadata(), timestamp, 1, key).add("col2", ByteBufferUtil.EMPTY_BYTE_BUFFER).build().applyUnsafe();
cfs.forceBlockingFlush();
new RowUpdateBuilder(cfs.metadata(), timestamp, 1, key).add("col3", ByteBufferUtil.EMPTY_BYTE_BUFFER).build().applyUnsafe();
cfs.forceBlockingFlush();
String noTTLKey = "nottl";
new RowUpdateBuilder(cfs.metadata(), timestamp, noTTLKey).add("col311", ByteBufferUtil.EMPTY_BYTE_BUFFER).build().applyUnsafe();
cfs.forceBlockingFlush();
// wait for ttl to expire
Thread.sleep(2000);
assertEquals(4, cfs.getLiveSSTables().size());
cfs.enableAutoCompaction(true);
assertEquals(1, cfs.getLiveSSTables().size());
SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
ISSTableScanner scanner = sstable.getScanner(ColumnFilter.all(cfs.metadata()), DataRange.allData(cfs.getPartitioner()));
assertTrue(scanner.hasNext());
while (scanner.hasNext()) {
UnfilteredRowIterator iter = scanner.next();
assertEquals(Util.dk(noTTLKey), iter.partitionKey());
}
scanner.close();
}
Aggregations