Passing list/map in lua function through PHP


#1

Hi All,

I am trying to aggregate a lua function which is taking list or map as an input and return the result on the basis of this input through PHP client.

Please suggest if there is any way to implementing this.


#2

There’s the aggregate() method in the PHP client. Take a look at the documentation to see if it fits what you want to do.


#3

Thanks Rbotzer,

I am using the aggregate() method in php but i am not able to pass list/map (array) in my lua function.

i am getting the following error.

Execution Error 2 : /usr/local/aerospike/lua/finalLua.lua:14: bad argument #1 to ‘pairs’ (table expected, got string)


#4

Seems like a bit of Lua debugging is needed. Can you share your Lua code?


#5

Hi

Here is my lua code.

If i hardcode the array then i able to run the lua but i am not able to pass the array in lua through PHP.

local function map_aud(record) if record.B1 ~= nil then return 1 end end

local function count_aud(a, b) return a + b end

function aud_filter(stream,f_array_bin) filter_array_bin = {} filter_array_bin = f_array_bin flag=false for k,v in pairs(filter_array_bin) do print(k,v) if record[‘B1’] and record[k] == v then flag=true else flag=false break end end

return stream :map(map_aud) : reduce(count_aud)

end