Multi get support for LMAP/LLIST?

Instead of making multiple calls to aerospike for each ldt bin, is there any way to make just one call and retrieve all the bins ?
eg.Suppose a Record contains :
largeListBin1
largeListBin2
largeMapBin1
largeMapBin2

Now to retrieve all of the data I am making these calls :

  • client.getLargeMap(myPolicy, key, largeMapBin1, null)

    • myLargeMap1.scan()
  • client.getLargeMap(myPolicy, key, largeMapBin2, null)

    • myLargeMap2.scan()
  • client.getLargeList(myPolicy, key, largeListBin1, null)

    • myLargeList1.scan()
  • client.getLargeList(myPolicy, key, largelistBin2, null)

    • myLargeList2.scan()

Is there any better way ? like client.getLargeMap(Policy policy, Key key, LargeMap lmap, Set<?> ldtKeys, null) If not then is there any plan to implement it in near future in Java Client. ?

Holmes,

You can use UDF to achieve this. Example multiGet.lua for 3 list bins would look like.

local llist = require("ldt/lib_llist");
function multiMapGet(rec, binNameList)
  if (not aerospike:exists(rec)) then
    return nil;
  end
  local resultMap = map()
  for i = 1, #binNameList, 1 do
    local binName = binNameList[i];
    if (binName and llist.ldt_exists(rec, binName)) then
      resultMap[binName] = llist.scan(rec, binName);
    end
  end
  return resultMap;
end


aql> execute llist.add('bin1', 'JSON{"key":10, "value":10}') on test.demo where PK='1'
+-----+
| add |
+-----+
| 0   | 
+-----+
1 row in set (0.001 secs)

aql> execute llist.add('bin2', 'JSON{"key":10, "value":10}') on test.demo where PK='1'
+-----+
| add |
+-----+
| 0   | 
+-----+
1 row in set (0.000 secs)

aql> execute llist.add('bin3', 'JSON{"key":10, "value":10}') on test.demo where PK='1'
+-----+
| add | 
+-----+
| 0   |
+-----+
1 row in set (0.000 secs)

aql> register module 'multiGet.lua'
OK,  1 module added.

aql> execute multiGet.multiMapGet('JSON["bin1", "bin2", "bin3"]') on test.demo where PK='1'
+-----------------------------------------------------------------------------------------------------+
| multiMapGet                                                                                         |
+-----------------------------------------------------------------------------------------------------+
| {"bin1":[{"value":10, "key":10}], "bin2":[{"value":10, "key":10}], "bin3":[{"value":10, "key":10}]} |
+-----------------------------------------------------------------------------------------------------+
1 row in set (0.000 secs)

Please note scan would cache entire result set in memory and return it back to the client. So will need memory accordingly on server based on your TPS requirement.

– R

Yeah that should do. Thanks Raj !

Is there any plan ahead to move multiget to default ldt apis ?

Holmes,

No plans right now. Noted the request :smile:

– Raj