-1

I have written aerospike udf that do get and update. But i am getting exception "bad argument #1 to 'pairs' (table expected, got userdata)"

    function update_record( record, list_added, list_removed, bin_name) 
      local store_list = record[bin_name]
      -- get a list from database record. Create one if it doesn't exits
      if store_list == nil then
        store_list = map()
      end

       local final_map={}
         if store_list then
          for k, v in pairs(store_list) do
            final_map[k] = 1
            i = i+1
          end
        end
  end

My Questions are:

  1. does aerospike retrun map(table) and if yes then whether we can use that return value as map(table) inside lua code

  2. If not then what is the best approach to get and store map in aerospike

I want to store map[Integer, Integer] in aerospike bin.

visingh
  • 233
  • 3
  • 17

1 Answers1

0

A good reference for this is the Aerospike documentation: http://www.aerospike.com/docs/udf/api/map.html

I have never heard of Aerospike before, but it looks like map provides its own iterator map.pairs.

So simply do something like

for k,v in map.pairs(store_list) do end 

...

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Piglet
  • 27,501
  • 3
  • 20
  • 43