Atomic Operations on List and Map Data Types - C, Java, and Go clients

Thx for the hints. I also think there is a need for such API, and I saw at least one another thread someone asked about this feature.

With your hints and some reading on the [UDF developer guide] (, I am able to develop a Lua UDF that meet my need. As an example for other people who may be interested, details are as follows:

  • map_ext.lua
function putAll(rec, bin, val)
    local m1 = rec[bin]
    if m1==nil  then m1 = map() end
    local m2 = val
    local m3 = map.merge( m1, m2, function(v1, v2)
        return v2
    end )
    rec[bin] = m3
    info("putAll() - m1: %s, m2: %s, m3: %s", tostring(m1), tostring(m2), tostring(m3))

    if aerospike:exists(rec) then aerospike:update(rec) else aerospike:create(rec) end
  • Register with AQL
  register module 'map_ext.lua'
  • Call in Java as
                new WritePolicy(),
                new Key("MyNameSpace", "MySet", "MyRecordKey"),
                "map_ext", "putAll",
                Value.getAsMap(new HashMap() {{
                    put("A", 1);
                    put("B", 2);
  • some hints:
    • read the developer guide, esp the best practice section. it mentioned about disable lua cache, and the registered lua script will show up at “/opt/aerospike/usr/udf/lua” by default. Using splitted windows to edit and execute the code.
    • for Java, there is a com.aerospike.examples.UserDefinedFunction example that show how to call UDF