Search in sources :

Example 31 with QueryPath

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

the class RemoveColumnTest method testRemoveColumn.

@Test
public void testRemoveColumn() throws IOException, ExecutionException, InterruptedException {
    Table table = Table.open("Keyspace1");
    ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
    RowMutation rm;
    DecoratedKey dk = Util.dk("key1");
    // add data
    rm = new RowMutation("Keyspace1", dk.key);
    rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column1")), ByteBufferUtil.bytes("asdf"), 0);
    rm.apply();
    store.forceBlockingFlush();
    // remove
    rm = new RowMutation("Keyspace1", dk.key);
    rm.delete(new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column1")), 1);
    rm.apply();
    ColumnFamily retrieved = store.getColumnFamily(QueryFilter.getNamesFilter(dk, new QueryPath("Standard1"), ByteBufferUtil.bytes("Column1")));
    assert retrieved.getColumn(ByteBufferUtil.bytes("Column1")).isMarkedForDelete();
    assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
    assertNull(Util.cloneAndRemoveDeleted(store.getColumnFamily(QueryFilter.getIdentityFilter(dk, new QueryPath("Standard1"))), Integer.MAX_VALUE));
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

Example 32 with QueryPath

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

the class RemoveSubColumnTest method testRemoveSubColumn.

@Test
public void testRemoveSubColumn() throws IOException, ExecutionException, InterruptedException {
    Table table = Table.open("Keyspace1");
    ColumnFamilyStore store = table.getColumnFamilyStore("Super1");
    RowMutation rm;
    DecoratedKey dk = Util.dk("key1");
    // add data
    rm = new RowMutation("Keyspace1", dk.key);
    Util.addMutation(rm, "Super1", "SC1", 1, "asdf", 0);
    rm.apply();
    store.forceBlockingFlush();
    // remove
    rm = new RowMutation("Keyspace1", dk.key);
    rm.delete(new QueryPath("Super1", ByteBufferUtil.bytes("SC1"), getBytes(1L)), 1);
    rm.apply();
    ColumnFamily retrieved = store.getColumnFamily(QueryFilter.getIdentityFilter(dk, new QueryPath("Super1", ByteBufferUtil.bytes("SC1"))));
    assert retrieved.getColumn(ByteBufferUtil.bytes("SC1")).getSubColumn(getBytes(1L)).isMarkedForDelete();
    assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

Example 33 with QueryPath

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

the class CommitLogTest method testDontDeleteIfDirty.

@Test
public void testDontDeleteIfDirty() throws Exception {
    CommitLog.instance.resetUnsafe();
    // Roughly 32 MB mutation
    RowMutation rm = new RowMutation("Keyspace1", bytes("k"));
    rm.add(new QueryPath("Standard1", null, bytes("c1")), ByteBuffer.allocate(32 * 1024 * 1024), 0);
    // Adding it 5 times
    CommitLog.instance.add(rm);
    CommitLog.instance.add(rm);
    CommitLog.instance.add(rm);
    CommitLog.instance.add(rm);
    CommitLog.instance.add(rm);
    // Adding new mutation on another CF
    RowMutation rm2 = new RowMutation("Keyspace1", bytes("k"));
    rm2.add(new QueryPath("Standard2", null, bytes("c1")), ByteBuffer.allocate(4), 0);
    CommitLog.instance.add(rm2);
    assert CommitLog.instance.activeSegments() == 2 : "Expecting 2 segments, got " + CommitLog.instance.activeSegments();
    int cfid2 = rm2.getColumnFamilyIds().iterator().next();
    CommitLog.instance.discardCompletedSegments(cfid2, CommitLog.instance.getContext());
    // Assert we still have both our segment
    assert CommitLog.instance.activeSegments() == 2 : "Expecting 2 segments, got " + CommitLog.instance.activeSegments();
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

Example 34 with QueryPath

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

the class LazilyCompactedRowTest method testOneRowManyColumns.

@Test
public void testOneRowManyColumns() throws IOException, ExecutionException, InterruptedException, NoSuchAlgorithmException {
    CompactionManager.instance.disableAutoCompaction();
    Table table = Table.open("Keyspace1");
    ColumnFamilyStore cfs = table.getColumnFamilyStore("Standard1");
    ByteBuffer key = ByteBuffer.wrap("k".getBytes());
    RowMutation rm = new RowMutation("Keyspace1", key);
    for (int i = 0; i < 1000; i++) rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes(i)), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
    rm.apply();
    DataOutputBuffer out = new DataOutputBuffer();
    RowMutation.serializer().serialize(rm, out, MessagingService.version_);
    assert out.getLength() > DatabaseDescriptor.getColumnIndexSize();
    cfs.forceBlockingFlush();
    assertBytes(cfs, Integer.MAX_VALUE);
    assertDigest(cfs, Integer.MAX_VALUE);
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 35 with QueryPath

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

the class LazilyCompactedRowTest method testManyRows.

@Test
public void testManyRows() throws IOException, ExecutionException, InterruptedException, NoSuchAlgorithmException {
    CompactionManager.instance.disableAutoCompaction();
    Table table = Table.open("Keyspace1");
    ColumnFamilyStore cfs = table.getColumnFamilyStore("Standard1");
    final int ROWS_PER_SSTABLE = 10;
    for (int j = 0; j < (DatabaseDescriptor.getIndexInterval() * 3) / ROWS_PER_SSTABLE; j++) {
        for (int i = 0; i < ROWS_PER_SSTABLE; i++) {
            ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(i % 2));
            RowMutation rm = new RowMutation("Keyspace1", key);
            rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes(String.valueOf(i / 2))), ByteBufferUtil.EMPTY_BYTE_BUFFER, j * ROWS_PER_SSTABLE + i);
            rm.apply();
        }
        cfs.forceBlockingFlush();
    }
    assertBytes(cfs, Integer.MAX_VALUE);
    assertDigest(cfs, Integer.MAX_VALUE);
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

QueryPath (org.apache.cassandra.db.filter.QueryPath)123 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)11 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 IColumn (org.apache.cassandra.db.IColumn)6 ArrayList (java.util.ArrayList)5 PrintStream (java.io.PrintStream)4 UnknownHostException (java.net.UnknownHostException)4 HashSet (java.util.HashSet)4 DropColumnFamily (org.apache.cassandra.db.migration.DropColumnFamily)4