How can I delete multiple bins from all the records of a set in Aerospike using Aerospike Python Client udf? I tried passing one bin at a time to the udf and used scan to delete the bin from all the records, but this was very inefficient as expected. I also tried creating a list of bins in python and passing the list to the UDF. The following is the code for reference:
Suppose I have 2000 records and 200 bins with names '1', '2', '3' ... etc. I want to delete the bins from '1' to '99'. The namespace in use is testns and the set in use is udfBins. testUdf.lua is the lua file containing the udf and my_udf is the lua function name.
test.py
scan = client.scan("testns", "udfBins")
bins = [str(i) for i in range(1,366)]
# for i in range(1,100):
scan.apply("testUdf", "my_udf", [bins])
job_id = scan.execute_background()
while True:
response = client.job_info(job_id, aerospike.JOB_SCAN)
if response["status"] != aerospike.JOB_STATUS_INPROGRESS:
break
print("job done")
testUdf.lua
function my_udf(rec, bins)
info(bins)
for bin in python.iter(bins)
do
rec[bin] = nil
end
aerospike:update(rec)
end
The above code doesn't work and I'm unable to figure out the reason and the correct way to solve the problem in hand. Any help is highly appreciated.
Thanks a lot in advance