Skip to content

Order and compare collection elements

For the complete documentation index see: llms.txt

All documentation pages available in markdown.

Type order (ascending)

  • Unordered Maps do not have a guaranteed element order when read back, and their internal wire representation is not required to match any canonical order.
  • As of Aerospike Database 8.2.0, this no longer affects equality: expressions compare Maps by content regardless of subtype (Unordered, K-ordered, or KV-ordered). CDT *_by_value and *_by_value_list operations already compared Maps by content.
  • Ordered Maps have performance advantages. See Map performance.

Elements with different types are ordered based on their type.

  1. NIL
  2. BOOLEAN
  3. INTEGER
  4. STRING
  5. LIST
  6. MAP
  7. BYTES
  8. DOUBLE
  9. GEOJSON
  10. INF

NIL

The lowest valued type. NIL is a singleton. NIL is used as a lower bound in list and map interval and range operations.

NIL can be stored as a list element or a map value, and reads back successfully. Setting a top-level bin to NIL deletes the bin (and if it is the last bin on the record, the record is removed). NIL cannot be used as a map key.

BOOLEAN

False < True

INTEGER

Ordered by integer value.

STRING

Order by each byte in the string.

"aa" < "b"

Strings are assumed to have UTF-8 encoding. Expression comparison operators use this same UTF-8 byte order on String bins. See Compare String values.

LIST

Order by:

  1. Each element starting from index 0 [1, 2] < [1, 3]
  2. Element count [1, 2] < [1, 2, 1]

MAP

Order by:

  1. Element count
  2. Each key in order stored
  3. Map values if the corresponding map keys are equal

BYTES

Order by each byte in the string.

DOUBLE

Ordered by float value.

INF

The highest valued type. INF is a singleton. INF is used as an upper bound in list and map interval and range operations. Not a storage type. Storing INF in a list or map has undefined behavior.

Comparison

Wildcard

The singleton WILDCARD(*) type can be used as a value parameter in list and map *_by_value and *_by_value_list operations. When used as an element in a list, it matches any remaining elements from that position onward. Not a storage type. Storing WILDCARD in a list or map has undefined behavior.

Bin: [ [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3] ]

list_get_all_by_value([1, *]) -> [ [1, 1], [1, 2], [1, 3] ]

Intervals

Intervals are inclusive-exclusive by default: start <= elements < end

Bin: [ [1, 1], [1, 2], [2, 1], [2, 2], [3, 1] ]

list_get_by_value_interval(start=[1, NIL], end=[2, NIL]) -> [ [1, 1], [1, 2] ]

Using INF, we can get an inclusive-inclusive interval when using 2nd level lists.

list_get_by_value_interval(start=[1, NIL], end=[2, INF]) -> [ [1, 1], [1, 2], [2, 1], [2, 2] ]