Search in sources :

Example 51 with DecoratedKey

use of org.apache.cassandra.db.DecoratedKey in project eiger by wlloyd.

the class OneCompactionTest method testCompaction.

private void testCompaction(String columnFamilyName, int insertsPerTable) throws IOException, ExecutionException, InterruptedException {
    CompactionManager.instance.disableAutoCompaction();
    Table table = Table.open("Keyspace1");
    ColumnFamilyStore store = table.getColumnFamilyStore(columnFamilyName);
    Set<DecoratedKey> inserted = new HashSet<DecoratedKey>();
    for (int j = 0; j < insertsPerTable; j++) {
        DecoratedKey key = Util.dk(String.valueOf(j));
        RowMutation rm = new RowMutation("Keyspace1", key.key);
        rm.add(new QueryPath(columnFamilyName, null, ByteBufferUtil.bytes("0")), ByteBufferUtil.EMPTY_BYTE_BUFFER, j);
        rm.apply();
        inserted.add(key);
        store.forceBlockingFlush();
        assertEquals(inserted.size(), Util.getRangeSlice(store).size());
    }
    CompactionManager.instance.performMaximal(store);
    assertEquals(1, store.getSSTables().size());
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Table(org.apache.cassandra.db.Table) DecoratedKey(org.apache.cassandra.db.DecoratedKey) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) RowMutation(org.apache.cassandra.db.RowMutation) HashSet(java.util.HashSet)

Aggregations

DecoratedKey (org.apache.cassandra.db.DecoratedKey)51 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)23 Test (org.junit.Test)22 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)16 ByteBuffer (java.nio.ByteBuffer)14 Keyspace (org.apache.cassandra.db.Keyspace)12 RowUpdateBuilder (org.apache.cassandra.db.RowUpdateBuilder)10 ColumnFamily (org.apache.cassandra.db.ColumnFamily)8 QueryPath (org.apache.cassandra.db.filter.QueryPath)8 RowMutation (org.apache.cassandra.db.RowMutation)7 Table (org.apache.cassandra.db.Table)7 File (java.io.File)6 BufferDecoratedKey (org.apache.cassandra.db.BufferDecoratedKey)6 TableMetadata (org.apache.cassandra.schema.TableMetadata)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 RowIndexEntry (org.apache.cassandra.db.RowIndexEntry)4 Token (org.apache.cassandra.dht.Token)4 java.util (java.util)3 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)3