Search in sources :

Example 26 with QueryPath

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

the class CleanupHelper method readData.

/* usually used to populate the cache */
protected void readData(String keyspace, String columnFamily, int offset, int numberOfRows) throws IOException {
    ColumnFamilyStore store = Table.open(keyspace).getColumnFamilyStore(columnFamily);
    for (int i = offset; i < offset + numberOfRows; i++) {
        DecoratedKey key = Util.dk("key" + i);
        QueryPath path = new QueryPath(columnFamily, null, ByteBufferUtil.bytes("col" + i));
        store.getColumnFamily(key, path, ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, 1);
    }
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) DecoratedKey(org.apache.cassandra.db.DecoratedKey) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore)

Example 27 with QueryPath

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

the class ReadMessageTest method testGetColumn.

@Test
public void testGetColumn() throws IOException, ColumnFamilyNotDefinedException {
    Table table = Table.open("Keyspace1");
    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("abcd"), 0);
    rm.apply();
    ReadCommand command = new SliceByNamesReadCommand("Keyspace1", dk.key, new QueryPath("Standard1"), Arrays.asList(ByteBufferUtil.bytes("Column1")));
    Row row = command.getRow(table);
    IColumn col = row.cf.getColumn(ByteBufferUtil.bytes("Column1"));
    assertEquals(col.value(), ByteBuffer.wrap("abcd".getBytes()));
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

Example 28 with QueryPath

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

the class RemoveColumnFamilyTest method testRemoveColumnFamily.

@Test
public void testRemoveColumnFamily() 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();
    // remove
    rm = new RowMutation("Keyspace1", dk.key);
    rm.delete(new QueryPath("Standard1"), 1);
    rm.apply();
    ColumnFamily retrieved = store.getColumnFamily(QueryFilter.getIdentityFilter(dk, new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column1"))));
    assert retrieved.isMarkedForDelete();
    assertNull(retrieved.getColumn(ByteBufferUtil.bytes("Column1")));
    assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

Example 29 with QueryPath

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

the class RemoveColumnFamilyWithFlush1Test method testRemoveColumnFamilyWithFlush1.

@Test
public void testRemoveColumnFamilyWithFlush1() 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.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column2")), ByteBufferUtil.bytes("asdf"), 0);
    rm.apply();
    store.forceBlockingFlush();
    // remove
    rm = new RowMutation("Keyspace1", dk.key);
    rm.delete(new QueryPath("Standard1"), 1);
    rm.apply();
    ColumnFamily retrieved = store.getColumnFamily(QueryFilter.getIdentityFilter(dk, new QueryPath("Standard1")));
    assert retrieved.isMarkedForDelete();
    assertNull(retrieved.getColumn(ByteBufferUtil.bytes("Column1")));
    assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) Test(org.junit.Test)

Example 30 with QueryPath

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

the class RemoveColumnFamilyWithFlush2Test method testRemoveColumnFamilyWithFlush2.

@Test
public void testRemoveColumnFamilyWithFlush2() 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();
    // remove
    rm = new RowMutation("Keyspace1", dk.key);
    rm.delete(new QueryPath("Standard1"), 1);
    rm.apply();
    store.forceBlockingFlush();
    ColumnFamily retrieved = store.getColumnFamily(QueryFilter.getIdentityFilter(dk, new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column1"))));
    assert retrieved.isMarkedForDelete();
    assertNull(retrieved.getColumn(ByteBufferUtil.bytes("Column1")));
    assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) 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