Search code examples
luaaerospike

Creating Sorted Map within Lua UDF


In the Aerospike Java client, a sorted map can be created via the MapOrder property, such as MapOrder.KEY_ORDERED or MapOrder.KEY_VALUE_ORDERED.

Within a Lua UDF, the docs indicate several ways to create a CDT map, but none allow specifying a map order:

local m1 = map()                       -- create map
local m2 = map.create(100)             -- create with initial size
local m3 = map { a = 1, b = 2, c = 3 } -- create with initial state

Is it possible to do so purely within a Lua UDF? If so, how?


Solution

  • It doesn't seem possible to, within Lua, create a Map with non-default sort order (e.g. KEY_ORDER). However:

    1. If a record is created by the Java client with a certain Map Policy, the policy will be maintained even if the record is edited via Lua; and

    2. If a Map is created in Lua, the Java Client can set the map policy separately afterwards.