Zero-length digest in UDF

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.

Using record.digest() is correct, and I’m trying to reproduce the problem you are seeing. What OS and server version are you using?

I’m currently running Aerospike Community Edition build 3.3.19 on Ubuntu 14.04.1 LTS.

We’ve diagnosed the issue and will be putting out a fix soon. Thanks!

Hi!

Just to close the loop, we released a fix for this issue in our Server Release 3.4.1 (January 12, 2015). But you will want to upgrade to our latest Server Release, 3.5.4, which was released on March 10, 2015.

Best regards,

Maud