Search in sources :

Example 1 with DefaultCompactionWriter

use of org.apache.cassandra.db.compaction.writers.DefaultCompactionWriter in project cassandra by apache.

the class CompactionAwareWriterTest method testDefaultCompactionWriter.

@Test
public void testDefaultCompactionWriter() throws Throwable {
    Keyspace ks = Keyspace.open(KEYSPACE);
    ColumnFamilyStore cfs = ks.getColumnFamilyStore(TABLE);
    int rowCount = 1000;
    cfs.disableAutoCompaction();
    populate(rowCount);
    LifecycleTransaction txn = cfs.getTracker().tryModify(cfs.getLiveSSTables(), OperationType.COMPACTION);
    long beforeSize = txn.originals().iterator().next().onDiskLength();
    CompactionAwareWriter writer = new DefaultCompactionWriter(cfs, cfs.getDirectories(), txn, txn.originals());
    int rows = compact(cfs, txn, writer);
    assertEquals(1, cfs.getLiveSSTables().size());
    assertEquals(rowCount, rows);
    assertEquals(beforeSize, cfs.getLiveSSTables().iterator().next().onDiskLength());
    validateData(cfs, rowCount);
    cfs.truncateBlocking();
}
Also used : CompactionAwareWriter(org.apache.cassandra.db.compaction.writers.CompactionAwareWriter) DefaultCompactionWriter(org.apache.cassandra.db.compaction.writers.DefaultCompactionWriter) LifecycleTransaction(org.apache.cassandra.db.lifecycle.LifecycleTransaction)

Aggregations

CompactionAwareWriter (org.apache.cassandra.db.compaction.writers.CompactionAwareWriter)1 DefaultCompactionWriter (org.apache.cassandra.db.compaction.writers.DefaultCompactionWriter)1 LifecycleTransaction (org.apache.cassandra.db.lifecycle.LifecycleTransaction)1