Search in sources :

Example 81 with QueryPath

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

the class RemoveSuperColumnTest method testRemoveSuperColumnWithNewData.

@Test
public void testRemoveSuperColumnWithNewData() throws IOException, ExecutionException, InterruptedException {
    ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super2");
    RowMutation rm;
    DecoratedKey dk = Util.dk("key1");
    // add data
    rm = new RowMutation("Keyspace1", dk.key);
    addMutation(rm, "Super2", "SC1", 1, "val1", 0);
    rm.apply();
    store.forceBlockingFlush();
    // remove
    rm = new RowMutation("Keyspace1", dk.key);
    rm.delete(new QueryPath("Super2", ByteBufferUtil.bytes("SC1")), 1);
    rm.apply();
    // new data
    rm = new RowMutation("Keyspace1", dk.key);
    addMutation(rm, "Super2", "SC1", 2, "val2", 2);
    rm.apply();
    validateRemoveWithNewData(dk);
    store.forceBlockingFlush();
    validateRemoveWithNewData(dk);
    CompactionManager.instance.performMaximal(store);
    assertEquals(1, store.getSSTables().size());
    validateRemoveWithNewData(dk);
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

Example 82 with QueryPath

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

the class RemoveSuperColumnTest method testRemoveSuperColumnResurrection.

@Test
public void testRemoveSuperColumnResurrection() throws IOException, ExecutionException, InterruptedException {
    ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super2");
    RowMutation rm;
    DecoratedKey key = Util.dk("keyC");
    // add data
    rm = new RowMutation("Keyspace1", key.key);
    addMutation(rm, "Super2", "SC1", 1, "val1", 0);
    rm.apply();
    // remove
    rm = new RowMutation("Keyspace1", key.key);
    rm.delete(new QueryPath("Super2", ByteBufferUtil.bytes("SC1")), 1);
    rm.apply();
    assertNull(Util.cloneAndRemoveDeleted(store.getColumnFamily(QueryFilter.getNamesFilter(key, new QueryPath("Super2"), ByteBufferUtil.bytes("SC1"))), Integer.MAX_VALUE));
    // resurrect
    rm = new RowMutation("Keyspace1", key.key);
    addMutation(rm, "Super2", "SC1", 1, "val2", 2);
    rm.apply();
    // validate
    ColumnFamily cf = store.getColumnFamily(QueryFilter.getNamesFilter(key, new QueryPath("Super2"), ByteBufferUtil.bytes("SC1")));
    cf = Util.cloneAndRemoveDeleted(cf, Integer.MAX_VALUE);
    Collection<IColumn> subColumns = cf.getSortedColumns().iterator().next().getSubColumns();
    assert subColumns.size() == 1;
    assert subColumns.iterator().next().timestamp() == 2;
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

Example 83 with QueryPath

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

the class RemoveSuperColumnTest method testRemoveDeletedSubColumn.

@Test
public void testRemoveDeletedSubColumn() throws IOException, ExecutionException, InterruptedException {
    ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super3");
    RowMutation rm;
    DecoratedKey dk = Util.dk("key1");
    // add data
    rm = new RowMutation("Keyspace1", dk.key);
    addMutation(rm, "Super3", "SC1", 1, "val1", 0);
    addMutation(rm, "Super3", "SC1", 2, "val1", 0);
    rm.apply();
    store.forceBlockingFlush();
    // remove
    rm = new RowMutation("Keyspace1", dk.key);
    rm.delete(new QueryPath("Super3", ByteBufferUtil.bytes("SC1"), Util.getBytes(1L)), 1);
    rm.apply();
    validateRemoveSubColumn(dk);
    store.forceBlockingFlush();
    validateRemoveSubColumn(dk);
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

Example 84 with QueryPath

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

the class RemoveSuperColumnTest method testRemoveSuperColumn.

@Test
public void testRemoveSuperColumn() throws IOException, ExecutionException, InterruptedException {
    ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super1");
    RowMutation rm;
    DecoratedKey dk = Util.dk("key1");
    // add data
    rm = new RowMutation("Keyspace1", dk.key);
    addMutation(rm, "Super1", "SC1", 1, "val1", 0);
    rm.apply();
    store.forceBlockingFlush();
    // remove
    rm = new RowMutation("Keyspace1", dk.key);
    rm.delete(new QueryPath("Super1", ByteBufferUtil.bytes("SC1")), 1);
    rm.apply();
    validateRemoveTwoSources(dk);
    store.forceBlockingFlush();
    validateRemoveTwoSources(dk);
    CompactionManager.instance.performMaximal(store);
    assertEquals(1, store.getSSTables().size());
    validateRemoveCompacted(dk);
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

Example 85 with QueryPath

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

the class RowIterationTest method testRowIterationDeletion.

@Test
public void testRowIterationDeletion() 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 a row in first sstable
    RowMutation rm = new RowMutation(TABLE1, key.key);
    rm.delete(new QueryPath(CF_NAME, null, null), 0);
    rm.apply();
    store.forceBlockingFlush();
    ColumnFamily cf = Util.getRangeSlice(store).iterator().next().cf;
    assert cf != null;
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

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