Properly store record key and metadata in a mapped stream UDF

Hello! I’m writing a UDF that will return a filtered list of records. So far my UDF looks like this:

local function filterCounter(count)
    return function(rec)
        if rec['count'] >= count then
            return true
        else
            return false
        end
    end
end

local function mapRecord(rec)
    local result = map()
    result['key'] = record.key(rec)
    result['count'] = rec['count']
    result['ttl'] = record.ttl(rec)
    return result
end

function findByCounter(stream, count)
    local myfilter = filterCounter(count)
    return stream : filter(myfilter) : map(mapRecord)
end

But when I do a console.log from the node.js client, each record will look like this:

Record {
  key: null,
  bins: { key: '5', count:2, ttl: 10 },
  ttl: undefined,
  gen: undefined }

My question is, how can I store the relevant info from the record in the key, and ttl properties of the map object and not inisde the bins property? Thanks!

All data is handled inside bins, except for metadata like key/lut/ttl/gen/etc. Why is this problematic? What problem are you trying to solve?

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.