ListOperation.pop(binName, metaInfo.getIndex())
任何人都可以帮忙解决这个问题吗?我正在使用默认写入策略
按照文档创建列表弹出操作。 服务器返回指定索引处的项目并从列表箱中删除项目。
公共静态操作 pop(String binName, int index, CTX...ctx) {
return CDT.createOperation(POP, Operation.Type.CDT_MODIFY, binName, ctx, index);
}
Key myKey = new Key("test", "testset", "mykey");
String binName = "myList";
ListPolicy lPolicy = new ListPolicy(ListOrder.UNORDERED, ListWriteFlags.DEFAULT);
client.delete(null,myKey); //Start clean for test
client.operate(null, myKey, ListOperation.append(lPolicy, binName, Value.get(10)));
client.operate(null, myKey, ListOperation.append(lPolicy, binName, Value.get(5)));
client.operate(null, myKey, ListOperation.append(lPolicy, binName, Value.get(15)));
client.operate(null, myKey, ListOperation.append(lPolicy, binName, Value.get(20)));
System.out.println("My List: "+ client.get(null, myKey));
client.operate(null, myKey, ListOperation.pop(binName, 1) ); //Pop at index 1, (value = 5)
System.out.println("My List after pop: "+ client.get(null, myKey));
输出:
My List: (gen:4),(exp:428342885),(bins:(myList:[10, 5, 15, 20]))
My List after pop: (gen:5),(exp:428342885),(bins:(myList:[10, 15, 20]))