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

The Aerospike Knowledge Base has moved to https://support.aerospike.com. Content on https://discuss.aerospike.com is being migrated to either https://support.aerospike.com or https://docs.aerospike.com. Maintenance on articles stored in this repository ceased on December 31st 2022 and this article may be stale. If you have any questions, please do not hesitate to raise a case via https://support.aerospike.com.

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.