Skip to content
edwardcapriolo edited this page Jan 22, 2013 · 1 revision

A request (IntraReq) is one or more operations (IntraOp). Some operations such as setting keyspace column family, or assume would be repetitive to include in every request. They would also make the request and response object larger. The solution to this is using Sessions.

Construct the first request as normal.

IntraReq r = new IntraReq();
r.add( IntraOp.setKeyspaceOp("myks"));//0
r.add( IntraOp.setColumnFamilyOp("mycf")); //1
r.add( IntraOp.setAutotimestampOp() ); //2
r.add( IntraOp.setOp("a", "b", "c") ); //3
r.add( IntraOp.assumeOp("myks", "mycf", "value", "UTF-8") );//4

Add the saveState operation to the request.

r.add( IntraOp.saveState() );//5

After sending the request the server will reply to the save state operation with an ID. That id is used to attach the next request to that session.

int id = (Integer) res.getOpsRes().get(5);

IntraReq r2 = new IntraReq();
r2.add( IntraOp.restoreState(id) );//0
r2.add( IntraOp.setOp("d", "e", "f") );//1
r2.add( IntraOp.getOp("d", "e") ); //2