-
Notifications
You must be signed in to change notification settings - Fork 14
MultiBatches batches across multiple keyspaces
edwardcapriolo edited this page Feb 8, 2013
·
3 revisions
IntraVert allow the keyspace and column family to be set as a default for a session or request. However each operation or row can over ride the default. IntraVert batches are a List of Map where a map represents a column. In this example notice each insert is for a different keyspace and column family.
List<Map> batch = new ArrayList<Map>();
Map row = new HashMap();
row.put("keyspace","ks1");
row.put("columnfamily","cf1");
row.put("rowkey","mykey");
row.put("name","mycol");
row.put("value","myvalue");
batch.add(row);
row = new HashMap();
row.put("keyspace","ks2");
row.put("columnfamily","cf2");
row.put("rowkey","mykey2");
row.put("name","mycol2");
row.put("value","myvalue2");
batch.add(row);
Additionally multiple operations ,read, write, meta can be executed inside a single request.
IntraReq req = new IntraReq();
req.add( Operations.setAutotimestampOp() )
.add( Operations.createKsOp("ks1", 1))
.add( Operations.setKeyspaceOp("ks1"))
.add( Operations.createCfOp("cf1"))
.add( Operations.createKsOp("ks2", 1))
.add( Operations.setKeyspaceOp("ks2"))
.add( Operations.createCfOp("cf2"))
.add( Operations.batchSetOp(batch).set("timeout", 1000000))
.add( Operations.assumeOp("ks1", "cf1", "value", "UTF-8"))
.add( Operations.assumeOp("ks2", "cf2", "value", "UTF-8"))
.add( Operations.getOp("mykey", "mycol")
.set("keyspace", "ks1")
.set("columnfamily", "cf1"));