Search in sources :

Example 86 with QueryPath

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;
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

Example 87 with QueryPath

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;
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

Example 88 with QueryPath

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);
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 89 with QueryPath

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);
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) ByteBuffer(java.nio.ByteBuffer) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 90 with QueryPath

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();
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath)

Aggregations

QueryPath (org.apache.cassandra.db.filter.QueryPath)127 Test (org.junit.Test)67 ByteBuffer (java.nio.ByteBuffer)40 QueryFilter (org.apache.cassandra.db.filter.QueryFilter)22 ColumnFamily (org.apache.cassandra.db.ColumnFamily)14 RowMutation (org.apache.cassandra.db.RowMutation)12 File (java.io.File)10 SSTableReader (org.apache.cassandra.io.sstable.SSTableReader)10 IOException (java.io.IOException)8 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)8 DecoratedKey (org.apache.cassandra.db.DecoratedKey)8 Table (org.apache.cassandra.db.Table)8 SSTableUtils.tempSSTableFile (org.apache.cassandra.io.sstable.SSTableUtils.tempSSTableFile)8 WrappedRunnable (org.apache.cassandra.utils.WrappedRunnable)8 ArrayList (java.util.ArrayList)5 IColumn (org.apache.cassandra.db.IColumn)5 PrintStream (java.io.PrintStream)4 UnknownHostException (java.net.UnknownHostException)4 HashSet (java.util.HashSet)4 DropColumnFamily (org.apache.cassandra.db.migration.DropColumnFamily)4