I use a normal filter to run a search on a secondary index and then pass the results through a UDF to do additional filtering. In my main function I execute the function like so:
return stream : filter(create_filter_params(filters)) : map(map_record_passthru)
where create_filter_params
creates a function to do the additional filtering, returning a boolean. This function works and the correct records are being returned. map_record_passthru
is a utility function to convert the Record
objects to Map
objects so they can be returned back to my Java client. I had to implement this as Aerospike wouldn’t let me returns the records themselves.
function map_record_passthru(rec)
local m = map()
m._digest = tostring(record.digest(rec))
m._gen = record.gen(rec)
m._ttl = record.ttl(rec)
local names = record.bin_names(rec)
for i, name in ipairs(names) do
m[name] = rec[name]
end
return m
end
The problem is that when this map is returned to the client, _gen
is 1 (which seems odd), _ttl
is 0 (correct), and _digest
is nil
. I’ve tried reading the result of record.digest
in various other ways and the most I’ve been able to determine is that it’s a zero-length Bytes
value.
How do I get the digest of a record in this way? Am I solving the problem wrong? Is there another way of getting the primary key of a record? My end goal is to store the primary key as a reference.