LUA - record manipulation and streams


#1

Hi, I was looking into the way to filter some records and modify them using just LUA. Just for tests I tried breaking a bit functional paradigm by adding aerospike:remove(rec) inside map function ie. stream : filter(myFilterFunction) : map (myMapFunctionWithSideEffect)

When I ran this function from AQL (aggregate and execute) I did not notice any errors in the logs but records were not removed.

Is there a way to do some filtering & updates only using LUA?

For a moment being I achieved that in my java app by first retrieving keys I was interested in and then making modifications but I think executing such a one time jobs would be more convenient just in LUA.

thanks, Artur


#2

The stream aggregation framework is not the right fit for this use case. It is a read-only system at present. You can issue a scan-udf and, do the filtering & modification in the same UDF. i.e In the same UDF, first do whatever check you want to do

  • for the records which passed they check, you can do modify/delete etc.
  • for the records which did not pass the first check, the UDF will simply return and move to the next record.

#3

thanks, I will try that tomorrow. Artur