Search in sources :

Example 1 with MaxSSTableSizeWriter

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

the class CompactionAwareWriterTest method testMaxSSTableSizeWriter.

@Test
public void testMaxSSTableSizeWriter() throws Throwable {
    ColumnFamilyStore cfs = getColumnFamilyStore();
    cfs.disableAutoCompaction();
    int rowCount = 1000;
    populate(rowCount);
    LifecycleTransaction txn = cfs.getTracker().tryModify(cfs.getLiveSSTables(), OperationType.COMPACTION);
    long beforeSize = txn.originals().iterator().next().onDiskLength();
    int sstableSize = (int) beforeSize / 10;
    CompactionAwareWriter writer = new MaxSSTableSizeWriter(cfs, cfs.getDirectories(), txn, txn.originals(), sstableSize, 0);
    int rows = compact(cfs, txn, writer);
    assertEquals(10, cfs.getLiveSSTables().size());
    assertEquals(rowCount, rows);
    validateData(cfs, rowCount);
    cfs.truncateBlocking();
}
Also used : CompactionAwareWriter(org.apache.cassandra.db.compaction.writers.CompactionAwareWriter) MaxSSTableSizeWriter(org.apache.cassandra.db.compaction.writers.MaxSSTableSizeWriter) LifecycleTransaction(org.apache.cassandra.db.lifecycle.LifecycleTransaction)

Aggregations

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