Collection Element Ordering and Comparison
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.