Example usage for org.apache.cassandra.cql3 QueryProcessor process

List of usage examples for org.apache.cassandra.cql3 QueryProcessor process

Introduction

In this page you can find the example usage for org.apache.cassandra.cql3 QueryProcessor process.

Prototype

public static UntypedResultSet process(String query, ConsistencyLevel cl, List<ByteBuffer> values)
            throws RequestExecutionException 

Source Link

Usage

From source file:org.usergrid.vx.experimental.IntraServiceITest.java

License:Apache License

@Test
@RequiresColumnFamily(ksName = "myks", cfName = "mycf")
public void cqlEngineTest() throws Exception {
    IntraReq req = new IntraReq();
    req.add(Operations.setKeyspaceOp("myks")); // 0
    req.add(Operations.setColumnFamilyOp("mycf")); // 1
    req.add(Operations.setAutotimestampOp(true)); // 2
    req.add(Operations.setOp("rowa", "col1", "7")); // 3

    IntraClient2 ic = new IntraClient2("localhost", 8080);
    @SuppressWarnings("unused")
    IntraRes res = ic.sendBlocking(req);

    ThriftClientState tcs = new ThriftClientState();
    tcs.setKeyspace("myks");
    ResultMessage rm = QueryProcessor.process("select * from mycf", ConsistencyLevel.ONE, tcs.getQueryState());
    CqlResult cr = rm.toThriftResult();/*w ww .  j  a v a2s  . co m*/
    List<Column> cols = cr.getRows().get(0).getColumns();
    ByteBufferUtil.string(cols.get(0).bufferForName());
    ByteBufferUtil.string(cols.get(1).bufferForName());
    ByteBufferUtil.string(cols.get(2).bufferForName());
    ByteBufferUtil.string(cols.get(0).bufferForValue());
    ByteBufferUtil.string(cols.get(1).bufferForValue());
    ByteBufferUtil.string(cols.get(2).bufferForValue());
    assertNotNull(rm);
}