Order and compare collection elements
Type Order (Ascending)
- Unordered maps means we do not guarantee any order
- If this informal ordering changes and an application relies on it, the application could fail
- Ordered maps have performance advantages in 6.x
Elements with different types are ordered based on their type.
- NIL
- BOOLEAN
- INTEGER
- STRING
- LIST
- MAP
- BYTES
- DOUBLE
- GEOJSON
- INF
NIL
The lowest valued type. NIL is a singleton.
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.
LIST
Order by:
- Each element starting from index 0
[1, 2] < [1, 3]
- Element count
[1, 2] < [1, 2, 1]
MAP
Order by:
- Element count
- Each key in order stored
- Map values if the corresponding map keys are equal
There is a known issue where Map/List comparisons may be incorrect for maps/lists of different lengths. If planning to utilize comparisons, update to Aerospike Database version 4.3.1 or higher.
BYTES
Order by each byte in the string.
DOUBLE
Ordered by float value.
INF
Introduced in Aerospike Database version 4.3.1.
The highest valued type. INF is a singleton.
Not a storage type. Storing INF in a bin list or map has undefined behavior.
Introduced in Aerospike Database version 4.3.1.
Comparison
Wildcard
The singleton WILDCARD(*) type can be passed as parameters in certain operations. WILDCARD is not a storage type.
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] ]
Introduced in Aerospike Database version 4.3.1.
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] ]
INF
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] ]
Introduced in Aerospike Database version 4.3.1.