List append does not appear to work when manipulated using an UDF


#1

List append does not appear to work when manipulated using an UDF

Problem Description

When a list is manipulated in an UDF using stub code as shown below, the append does not work.

list.append(record.DeTargetCpID, campaignId)

The following code does work.

local dtcid = record.DeTargetCpID
list.append(dtcid, campaignId)
record.DeTargetCpID = dtcid
aerospike:update(record)

Explanation

When a list or map is manipulated within an UDF it then has to be assigned back to the bin or it will not be updated. This is by design. The reason for this is that the list or map is serialized into a byte stream to be stored in the bin on disk; this is a comparatively costly process.

For performance reasons, when an UDF manipulates a list or map, it does so in memory in a linked list or array list. This means that the serialization only needs happen when the list or map is written back to disk minimizing any performance hit.