-
Notifications
You must be signed in to change notification settings - Fork 14
Slice By Name
edwardcapriolo edited this page Feb 17, 2013
·
1 revision
Thrift supports slices by range and slices by name.
First insert some test data. IntraReq req = new IntraReq(); req.add( Operations.assumeOp("myks", "mycf", "value", "UTF-8")) .add(Operations.assumeOp("myks", "mycf", "column", "UTF-8")) .add(Operations.setKeyspaceOp("myks")) .add(Operations.setColumnFamilyOp("mycf")) .add(Operations.setOp("slicename", "ed", "NY")) // 4 .add(Operations.setOp("slicename", "bob", "NY"))// 5 .add(Operations.setOp("slicename", "pete", "FL"))// 6
The sliceByNames operation requires a row key and a list of wanted columns.
.add( Operations.sliceByNames("slicename", Arrays.asList(new Object [] { "ed","pete" })) );
Each column is returned as a transposed row.
List<Map> x = (List<Map>) res.getOpsRes().get(7);
Assert.assertEquals("ed", x.get(0).get("name"));
Assert.assertEquals("FL", x.get(1).get("value"));