How to handle MapOperation.increment() and Operation.get() operations in a single db operation?

When we execute Operation.get() operations with MapOperation.increment() in a single db operation like,

operations.add(Operation.add(new Bin(binName1), data1)));
operations.add(Operation.add(new Bin(binName2), data2)))
operations.add(MapOperation.increment(binName3, key, value));

Expected Value: -

(gen:4),(exp:263988757),(bins:(wd201740:2),(w_tg_201740:{f=2,e=2}))

What we get: -

(gen:4),(exp:263988757),(bins:(w_tg_201740:[2, null, 2, null, {f=2, e=2}]),(wd201740:null),(nsp_wt201740:null),(wt201740:[null, 4]))

Or

Expected Value:

(gen:6),(exp:263990995),(bins:(w_tg_201740: {f=4, e=4}))

What we get:

(gen:6),(exp:263990995),(bins:(w_tg_201740:[4, 4, {f=4, e=4}]))

i.e, we receive each bin as a list, instead of generic values stored at those bins.

What version of Aerospike server and client.

Difficult to figure out with variable names and such a short code snippet. Can you test and post a code snippet with actual data only. ie use actual strings for bin names and actual values for data and test and post results. Are you looping through these operations? On the same bin (binName2) you are doing an add operation and then a Map operation… what are you expecting?

1 Like

We are doing add operation and Map operation on different bin names (binName2–>binName3).

final Key key = new Key(NAMESPACE, "setString", "keyString");

final List<Operation> operations = new ArrayList<Operation>();
operations.add(Operation.add(new Bin("wt201740"), 1024)));
operations.add(Operation.add(new Bin("wd201740"), 1000)));

//map = {f:1024,e:1024}
for(Map.Entry<String, String> entry : map.entrySet()){
	operations.add(MapOperation.increment(new MapPolicy(), "w_tg_201740", Value.get(entry.getKey()), Value.get(entry.getValue)));
}
		
operations.add(Operation.get("wt201740"));
operations.add(Operation.get("w_tg_201740"));

final Operation[] op == new Operation[operations.size()];
operations.toArray(op);

final Record record = repository.operate(WritePolicy, key, op);

expected : (gen:4),(exp:263988757),(bins:(wt201740:1024),(w_tg_201740:{f=1024,e=1024}))

reality : (gen:4),(exp:263988757),(bins:(w_tg_201740:[1024, null, 1024, null, {f=1024, e=1024}]),(wt201740:[null, 1024]))

We get a list and not the corresponding values for the respective bins. We get the desired result when we comment out MapOperation.insert() operation.