@raj
Thanks for your reply! I am infact using the same policy when calling the execute() call but it doesn’t affect the record created with the UDF. Here’s my test example that I’ve been using:
keyValue = "user1";
binName = "testBin";
valueMap = ImmutableMap.of("test", 1);
Map.Entry<String, ?> entry = valueMap.entrySet().iterator().next();
Key udfKey = new Key(nsName, setName, keyValue + "_udf");
aerospikeClient.execute(writePolicy, udfKey, "map_ops", "updateMap",
Value.get(binName), Value.get(entry.getKey()), Value.get(entry.getValue()));
System.out.println("Stored with udf " + Buffer.bytesToHexString(udfKey.digest) + ", sendKey=" + writePolicy.sendKey);
Key putKey = new Key(nsName, setName, keyValue + "_put");
aerospikeClient.put(writePolicy, putKey, Bin.asMap(binName, valueMap));
System.out.println("Stored with put " + Buffer.bytesToHexString(putKey.digest) + ", sendKey=" + writePolicy.sendKey);
aerospikeClient.scanAll(null, nsName, setName, new ScanCallback() {
@Override public void scanCallback(Key key, Record record) throws AerospikeException {
System.out.println("key: " + key.toString() + ", record:" + record.toString());
}
});
The udf used is a generic update or create a map entry from https://github.com/adform/trident-aerospike/blob/master/udf/map_ops.lua
This produces the output (note user1_put vs null in the key):
Stored with udf e26dc422ffd6d0fbb22d58119fec48a7282d02aa, sendKey=true
Stored with put 19d1937188e557ef9cdec8277cb59438f206ed2a, sendKey=true
key: teststore:keytest:user1_put:19d1937188e557ef9cdec8277cb59438f206ed2a, record:(gen:1),(exp:184781343),(bins:(testBin:{test=1}))
key: teststore:keytest:null:e26dc422ffd6d0fbb22d58119fec48a7282d02aa, record:(gen:1),(exp:0),(bins:(testBin:{test=1}))
And similarly with aql you can see the key for one but not the other:
select * from teststore.keytest
+-------------+------------+
| key | testBin |
+-------------+------------+
| "user1_put" | {"test":1} |
| | {"test":1} |
+-------------+------------+
Am I missing anything?
P.S. I guess the same applies for the TTL sent (I assume that’s what exp:184781343
means)