-
Notifications
You must be signed in to change notification settings - Fork 14
CQL Support
edwardcapriolo edited this page Jan 22, 2013
·
2 revisions
IntraVert is NoCQL (Not Only CQL). IntraVert does offer a CQL verb allowing the user to use CQL directly. CQL results are transposed by default allow them to be fed into other Invert verbs like Process or MultiProcess.
This example will create a keyspace, column family, and data to populate it.
req.add( Operations.setKeyspaceOp("cqlks") ); //0
req.add( Operations.createKsOp("cqlks", 1)); //1
req.add( Operations.createCfOp("cqlcf")); //2
req.add( Operations.setColumnFamilyOp("cqlcf") ); //3
req.add( Operations.setAutotimestampOp() ); //4
req.add( Operations.assumeOp("cqlks", "cqlcf", "value", "int32"));//5
req.add( Operations.assumeOp("cqlks", "cqlcf", "column", "int32"));//6
req.add( Operations.setOp("rowa", 1, 2)); //7
req.add( Operations.getOp("rowa", 1)); //8
Next we can issue a request through the cqlQuery operation. the first argument is the query and the second argument is the CQL version.
req.add( Operations.cqlQuery("select * from cqlcf", "3.0.0"));//9
The results are transposed to match the style of IntraVert get and slice operations.
List<Map> x = (List<Map>) res.getOpsRes().get(8);
Assert.assertEquals( 1, x.get(0).get("name") );
Assert.assertEquals( 2, x.get(0).get("value") );
x = (List<Map>) res.getOpsRes().get(9);
Assert.assertEquals( new Integer(2), Int32Type.instance.compose((ByteBuffer)x.get(2).get("value")));