Search code examples
aerospike

Aerospike ListOperation usage in Java client


I'm getting started with the ListOperation in the Java client, and the operations do not work as expected. Here are my code:

AerospikeClient client = new AerospikeClient("10.0.0.1", 3000);
Key key = new Key("test", "demo", "testlist");

Value vll = Value.get(123);

List<Value> itemList = new ArrayList<Value>();
itemList.add(Value.get("s11"));
itemList.add(Value.get("s22222"));
Bin bin01 = new Bin("bin3", Value.get(itemList));

client.put(null, key, bin01);
Record record0 = client.operate(null, key, Operation.put(new Bin("bin4", 90)), ListOperation.insertItems("bin6", 0, itemList) , Operation.get());
System.out.println("record0");
System.out.println(record0);
Record record1 = client.operate(null, key, ListOperation.append("bin3", vll), Operation.get());
System.out.println("record1");
System.out.println(record1);

itemList.add(Value.get("s3333333"));
itemList.add(Value.get("s4444444444"));
itemList.add(Value.get("s5555555555555555"));
Record record2 = client.operate(null, key,
        ListOperation.insertItems("bin3", 0, itemList), Operation.get()
);
System.out.println("record2");
System.out.println(record2);

Record record3 = client.get(null, key);
System.out.println("record3");
System.out.println(record3);

And here are the output:

record0 (gen:2),(exp:239021264),(bins:(bin3:[s11, s22222]),(bin4:90)) record1 (gen:3),(exp:239021264),(bins:(bin3:[s11, s22222]),(bin4:90)) record2 (gen:4),(exp:239021265),(bins:(bin3:[s11, s22222]),(bin4:90)) record3 (gen:4),(exp:239021265),(bins:(bin3:[s11, s22222]),(bin4:90))

It seems that all of the ListOperations used in my code were not applied. Am I using it wrong?

Thanks.


Solution

  • Need Server version 3.7.0.1+ to do the above ListOperations. Testing on ver 3.3.21.