Skip to content

Map operations

For the complete documentation index see: llms.txt

All documentation pages available in markdown.

Map operations read, update, and remove elements in map-type bins directly on the server.

These operations have expression counterparts, which evaluate to a value instead of writing it. See Map expressions for the set, and Operations and expressions for which to reach for.

Each operation is governed by a map policy (order, write flags, PERSIST_INDEX), can target nested elements using a context, and returns results controlled by a return type.

Map policy

The map policy defines the characteristics of a map write operation.

Map order

The map order is set in the map policy and determines the map subtype. The order type determines how the server accesses map elements:

  • Unordered — no ordering guarantees. Key lookup is a linear scan. Lowest storage overhead.
  • K-ordered — elements are maintained in key order. Key lookup uses binary search. Without a persisted index, the key offset index is built temporarily per operation at O(N) cost.
  • KV-ordered — elements are maintained in key and value order. Without a persisted full index, rank and value lookups use the same heap/scan fallback as K-ordered (the value order index is not built on-demand). With a persisted full index, rank lookups are O(1) and value searches are O(log N).

Use set_type() to convert between order types. See Map performance for the operational complexity of each order type.

Persisting the map index

For large maps with a high read-to-write ratio, rebuilding the offset index on every access can consume significant CPU. Setting PERSIST_INDEX in the map policy stores the index on disk alongside the map itself, so subsequent operations load it directly instead of rebuilding it.

PERSIST_INDEX is set per write and applies only to the top-level map, not nested maps.

Setting PERSIST_INDEX on an unordered map sorts its keys into key order and persists the offset index, giving it the same binary-search key lookup behavior as a K-ordered map with a persisted index (column 3 in the performance table).

Write flags

FlagDescription
MODIFY_DEFAULTDefault: upserts; create or update map keys
CREATE_ONLYOnly create new map keys. Fail if the key already exists
UPDATE_ONLYOnly update existing map keys. Fail if a key does not exist
NO_FAILNo-op instead of fail if a policy violation occurred, such as CREATE_ONLY
DO_PARTIALWhen used with NO_FAIL, add elements that did not violate a policy

Write flags can be combined using bitwise OR. For example, UPDATE_ONLY | NO_FAIL | DO_PARTIAL updates existing keys, skips keys that do not exist, and applies the remaining updates without failing.

Context

Context TypeDescription
MAP_INDEXFinds an element in a Map by index. A negative index is a lookup performed in reverse from the end of the map. If it is out of bounds, a parameter error is returned.
MAP_KEYFinds an element in a Map by key.
MAP_RANKFinds an element in a Map by rank. A negative rank is a lookup performed in reverse from the highest ranked.
MAP_VALUEFinds an element in a Map by value.
MAP_KEY_CREATEFinds an element in a Map by key. Creates the element if it does not exist.

The context is a list of element selectors describing a path to the nested map element where the operation should be applied. Without a context it is assumed that the operation occurs at the top level of the map.

Return types

Return TypeDescription
KEYThe key of the element (in single result operations) or elements (in multi result operations)
VALUEThe value of the element (in single result operations) or elements (in multi result operations)
KEY_VALUEThe key/value pair of the element (in single result operations) or elements (in multi result operations)
ORDERED_MAPReturns results as an ordered Map
UNORDERED_MAPReturns results as an unordered Map
NONENothing is returned. It speeds up remove operations by not constructing a reply
COUNTNumber of elements returned
INDEXKey order position of the element, from 0 (smallest key) to N-1 (largest)
REVERSE_INDEXReverse key order position of the element, from 0 (largest key) to N-1 (smallest)
RANKValue order of the element, with 0 being the smallest value
REVERSE_RANKReverse value order of the element, with 0 being the largest value
INVERTEDInvert meaning of map command and return values. Combine with another return type using bitwise OR, such as `COUNT
EXISTSReturns a boolean true if any elements match the criteria. For example, get_all_by_value with EXISTS returns true if the value is in the map.

Examples

  • Remove the 10 map elements with the largest key values: remove_by_index_range(-10, 10, NONE)
  • Remove all but the 10 map elements with the largest key values: remove_by_index_range(-10, 10, NONE | INVERTED)
  • Keep only the top 10 key elements and return the count of removed elements: remove_by_index_range(-10, 10, COUNT | INVERTED)

Modify operations

clear

clear(bin_name[, context])
Description

Clears the map. Map type stays the same.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

null

Expression form
Code sample
// m = {a: 1, b: 2, c: 3}
try (RecordStream rs = session.upsert(key)
.bin("m").mapClear()
.execute()) {
Record rec = rs.next().recordOrThrow();
}
// m == {}

decrement

decrement(policy, bin_name, key, delta[, context])
Description

Decrements values by delta-value for all items identified by key.

Only works for integer or float value types in the {key: value} pair. If the bin does not exist, a new unordered map is created unless a different map order is specified through the map policy.

Type interaction between value and delta-value

Value-TypeDelta: integerDelta: float
Map Entry: integerSubtract normallyTruncate to nearest integer and subtract
Map Entry: floatConvert integer to float and subtractSubtract normally
Arguments
NameTypeDescription
policyMap policy

Ordering and write flags for the operation. See Write flags. The ordering attribute takes effect only when this operation creates the map; on a map that already exists it is ignored.

bin_namestring

Name of the bin to operate on.

keyany

Map key whose value is decremented.

deltainteger or float

Amount to subtract. A negative value adds.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

New value after decrement

Code sample
// m = {a: 1, b: 10, c: 3}
// Decrement by incrementing with a negative value.
try (RecordStream rs = session.upsert(key)
.bin("m").onMapKey("b").add(-3)
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns 7 (new value of key "b")
}
// m == {a: 1, b: 7, c: 3}

increment

increment(policy, bin_name, key, delta[, context])
Description

Increments values by delta-value for all items identified by key.

Only works for integer or float value types in the {key: value} pair. If the bin does not exist, a new unordered map is created unless a different map order is specified through the map policy.

Type interaction between value and delta-value

Value-TypeDelta: integerDelta: float
Map Entry: integerAdd normallyTruncate to nearest integer and add
Map Entry: floatConvert integer to float and addAdd normally
Arguments
NameTypeDescription
policyMap policy

Ordering and write flags for the operation. See Write flags. The ordering attribute takes effect only when this operation creates the map; on a map that already exists it is ignored.

bin_namestring

Name of the bin to operate on.

keyany

Map key whose value is incremented.

deltainteger or float

Amount to add. A negative value subtracts.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

New value after increment

Expression form
Code sample
// m = {a: 1, b: 2, c: 3}
try (RecordStream rs = session.upsert(key)
.bin("m").onMapKey("b").add(10)
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns 12 (new value of key "b")
}
// m == {a: 1, b: 12, c: 3}

put_items

put_items(policy, bin_name, items[, context])
Description

Creates a map bin with a specified order, if the bin does not exist. Takes a map of key/value items and adds them to the map bin.

Arguments
NameTypeDescription
policyMap policy

Ordering and write flags for the operation. See Write flags. The ordering attribute takes effect only when this operation creates the map; on a map that already exists it is ignored.

bin_namestring

Name of the bin to operate on.

itemsmap

Key/value pairs to write, as a map. A key already present is overwritten; a key that is absent is added.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

The element count of the map after the operation, in the ‘bins’ part of the record under the bin name.

Expression form
Order

If the bin does not exist, a new unordered map is created unless a different map order is specified through the map policy.

K_ORDERED maps are preferred over UNORDERED maps, with no real disadvantage in terms of space used.

Code sample
// m = {a: 1}
try (RecordStream rs = session.upsert(key)
.bin("m").mapUpsertItems(Map.of("b", 2, "c", 3))
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns 3 (new map size)
}
// m == {a: 1, b: 2, c: 3}

put

put(policy, bin_name, key, value[, context])
Description

Creates a map bin with a specified order, if the bin does not exist. Adds a key/value element to the map.

Arguments
NameTypeDescription
policyMap policy

Ordering and write flags for the operation. See Write flags. The ordering attribute takes effect only when this operation creates the map; on a map that already exists it is ignored.

bin_namestring

Name of the bin to operate on.

keyany

Map key to write.

valueany

Value to store under key, replacing any value already there.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

The element count of the map after the operation, in the ‘bins’ part of the record under the bin name.

Expression form
Order

If the bin does not exist, a new unordered map is created unless a different map order is specified through the map policy.

K_ORDERED maps are preferred over UNORDERED maps, with no real disadvantage in terms of space used.

Performance

With a persisted index, ordered maps have 𝓞(log N) worst-case performance. Without a persisted index or for unordered maps, the worst-case performance is 𝓞(N). See Map performance.

Code sample
// m = {a: 1}
try (RecordStream rs = session.upsert(key)
.bin("m").onMapKey("b").setTo(2)
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns 2 (new map size)
}
// m == {a: 1, b: 2}

remove_all_by_key_list

remove_by_key_list(bin_name, keys, result_type[, context])
Description

Remove all {key: value} pairs where map.key ∈ keyList.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

keyslist

Keys to match, as a list.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Expression form
Performance

Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5}
try (RecordStream rs = session.upsert(key)
.bin("m").onMapKeyList(List.of("a", "c", "e")).removeAnd().getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {a: 1, c: 3, e: 5}
}
// m == {b: 2, d: 4}

remove_all_by_value_list

remove_by_value_list(bin_name, values, result_type[, context])
Description

Remove all {key: value} pairs where map.value ∈ valueList.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

valueslist

Values to match, as a list. Every entry whose value equals any of them is selected.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Expression form
Performance

Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5}
try (RecordStream rs = session.upsert(key)
.bin("m").onMapValueList(List.of(2, 4)).removeAnd().getKeys()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns [b, d]
}
// m == {a: 1, c: 3, e: 5}

remove_all_by_value

remove_by_value(bin_name, value, result_type[, context])
Description

Remove all {key: value} pairs where map.value == value.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

valueany

Value to match. Every entry whose value equals it is selected.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Expression form
Performance

Requesting an INDEX return type adds 𝓞(N + M) on an unordered map, or 𝓞(M) on a map with a persisted offset index. Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 1, d: 3}
try (RecordStream rs = session.upsert(key)
.bin("m").onMapValue(1).removeAnd().getKeys()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns [a, c] (keys of removed entries)
}
// m == {b: 2, d: 3}

remove_by_index_range

remove_by_index_range(bin_name, index[, count], result_type[, context])
Description

Remove all {key: value} pairs where k = indexof(map.key) and k >= index and k < index + count. Omitting count select element(s) where k >= origin + index.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

indexinteger

Zero-based position, 0 being the first element. A negative index counts back from the end.

countinteger

Number of elements to select. Optional; defaults to the rest of the collection.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Performance

Requesting a RANK return type adds 𝓞(N log N). Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5} (K_ORDERED)
try (RecordStream rs = session.upsert(key)
.bin("m").onMapIndexRange(1, 2).removeAnd().getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {b: 2, c: 3}
}
// m == {a: 1, d: 4, e: 5}

remove_by_index

remove_by_index(bin_name, index, result_type[, context])
Description

Remove {key: value} entry where map.key is the ith smallest key where i == index.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

indexinteger

Zero-based position, 0 being the first element. A negative index counts back from the end.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Single result

Expression form
Performance

Requesting a RANK return type adds 𝓞(N), or 𝓞(log N) with a persisted full index. Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3} (K_ORDERED)
try (RecordStream rs = session.upsert(key)
.bin("m").onMapIndex(0).removeAnd().getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {a: 1} (smallest key removed)
}
// m == {b: 2, c: 3}

remove_by_key_interval

remove_by_key_range(bin_name, key_begin, key_end, result_type[, context])
Description

Remove all {key: value} pairs where map.key >= keyStart and map.key < keyStop. Omitting keyStop select element(s) where map.key >= keyStart.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

key_beginany

Lowest key to match, inclusive.

key_endany

Upper bound on the key, exclusive. Omit it to match everything from key_begin upward.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Expression form
Performance

Requesting a RANK return type adds 𝓞(N log N). Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5}
try (RecordStream rs = session.upsert(key)
.bin("m").onMapKeyRange("b", "d").removeAnd().getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {b: 2, c: 3} (keys >= "b" and < "d")
}
// m == {a: 1, d: 4, e: 5}

remove_by_key_rel_index_range

remove_by_key_rel_index_range(bin_name, key, index[, count], result_type[, context])
Description

Remove all {key: value} pairs where origin = index(key), k = indexof(map.key) and k >= origin + index and k < origin + index + count. Omitting count select element(s) where k >= origin + index.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

keyany

Key that index is measured from. It need not be present in the map — the index is taken from where it would sort.

indexinteger

Zero-based position, 0 being the first element. A negative index counts back from the end.

countinteger

Number of elements to select. Optional; defaults to the rest of the collection.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5} (K_ORDERED)
// From key "b" (index 1), offset 0, count 3
try (RecordStream rs = session.upsert(key)
.bin("m").onMapKeyRelativeIndexRange("b", 0, 3).removeAnd().getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {b: 2, c: 3, d: 4}
}
// m == {a: 1, e: 5}

remove_by_key

remove_by_key(bin_name, key, result_type[, context])
Description

Remove entry {key: value} where map.key == key.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

keyany

Map key to match.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Single result

Expression form
Performance

Requesting an INDEX return type adds 𝓞(N), or 𝓞(log N) with a persisted index. Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3}
try (RecordStream rs = session.upsert(key)
.bin("m").onMapKey("b").removeAnd().getValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns 2 (removed value)
}
// m == {a: 1, c: 3}

remove_by_rank_range

remove_by_rank_range(bin_name, rank[, count], result_type[, context])
Description

Remove all {key: value} pairs where r = rankof(map.value) and r >= rank and r < rank + count. Omitting count select element(s) where r >= rank.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

rankinteger

Zero-based rank in value order, 0 being the smallest. A negative rank counts back from the largest.

countinteger

Number of elements to select. Optional; defaults to the rest of the collection.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Performance

Requesting an INDEX return type adds 𝓞(N log N) on an unordered map, or 𝓞(M) on a map with a persisted offset index. Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 3, b: 1, c: 5, d: 2, e: 4}
try (RecordStream rs = session.upsert(key)
.bin("m").onMapRankRange(0, 2).removeAnd().getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {b: 1, d: 2} (2 smallest values removed)
}
// m == {a: 3, c: 5, e: 4}

remove_by_rank

remove_by_rank(bin_name, rank, result_type[, context])
Description

Remove {key: value} entry where map.value is the ith smallest value where i == rank.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

rankinteger

Zero-based rank in value order, 0 being the smallest. A negative rank counts back from the largest.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Single result

Expression form
Performance

Requesting an INDEX return type adds 𝓞(N) on an unordered map, or 𝓞(1) on a map with a persisted offset index. Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 3, b: 1, c: 2}
try (RecordStream rs = session.upsert(key)
.bin("m").onMapRank(0).removeAnd().getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {b: 1} (smallest value removed)
}
// m == {a: 3, c: 2}

remove_by_value_interval

remove_by_value_range(bin_name, value_begin, value_end, result_type[, context])
Description

Remove all {key: value} pairs where map.value >= valueStart and map.value < valueStop. Omitting valueStop select element(s) where map.value >= valueStart.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

value_beginany

Lowest value to match, inclusive.

value_endany

Upper bound on the value, exclusive. Omit it to match everything from value_begin upward.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Expression form
Performance

Requesting an INDEX return type adds 𝓞(N + M) on an unordered map, or 𝓞(M) on a map with a persisted offset index. Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5}
try (RecordStream rs = session.upsert(key)
.bin("m").onMapValueRange(2, 4).removeAnd().getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {b: 2, c: 3} (values >= 2 and < 4)
}
// m == {a: 1, d: 4, e: 5}

remove_by_value_rel_rank_range

remove_by_value_rel_rank_range(bin_name, value, rank[, count], result_type[, context])
Description

Remove all {key: value} pairs where origin = rank(value), r = rankof(map.value) and r >= origin + rank and r < origin + rank + count. Omitting count select element(s) where r >= origin + rank.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

valueany

Value that rank is measured from. It need not be present in the collection — the rank is taken from where it would sort.

rankinteger

Zero-based rank in value order, 0 being the smallest. A negative rank counts back from the largest.

countinteger

Number of elements to select. Optional; defaults to the rest of the collection.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5}
// From value 3 (rank 2), offset 0, count 2
try (RecordStream rs = session.upsert(key)
.bin("m").onMapValueRelativeRankRange(3, 0, 2).removeAnd().getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {c: 3, d: 4}
}
// m == {a: 1, b: 2, e: 5}

Read operations

get_all_by_key_list

get_by_key_list(bin_name, keys, result_type[, context])
Description

Get all {key: value} pairs where map.key ∈ keyList.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

keyslist

Keys to match, as a list.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Expression form
Performance

Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5}
try (RecordStream rs = session.query(key)
.bin("m").onMapKeyList(List.of("a", "c", "e")).getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {a: 1, c: 3, e: 5}
}

get_all_by_value_list

get_by_value_list(bin_name, values, result_type[, context])
Description

Get all {key: value} pairs where map.value ∈ valueList.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

valueslist

Values to match, as a list. Every entry whose value equals any of them is selected.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Expression form
Performance

Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5}
try (RecordStream rs = session.query(key)
.bin("m").onMapValueList(List.of(2, 4)).getKeys()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns [b, d]
}

get_all_by_value

get_by_value(bin_name, value, result_type[, context])
Description

Get all {key: value} pairs where map.value == value.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

valueany

Value to match. Every entry whose value equals it is selected.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Expression form
Performance

Requesting an INDEX return type adds 𝓞(N + M) on an unordered map, or 𝓞(M) on a map with a persisted offset index. Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 1, d: 3}
try (RecordStream rs = session.query(key)
.bin("m").onMapValue(1).getKeys()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns [a, c] (all keys with value == 1)
}

get_by_index_range

get_by_index_range(bin_name, index[, count], result_type[, context])
Description

Get all {key: value} pairs where k = indexof(map.key) and k >= index and k < index + count. Omitting count select element(s) where k >= origin + index.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

indexinteger

Zero-based position, 0 being the first element. A negative index counts back from the end.

countinteger

Number of elements to select. Optional; defaults to the rest of the collection.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Performance

Requesting a RANK return type adds 𝓞(N log N). Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5} (K_ORDERED)
try (RecordStream rs = session.query(key)
.bin("m").onMapIndexRange(1, 2).getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {b: 2, c: 3} (2 entries starting at index 1)
}

get_by_index

get_by_index(bin_name, index, result_type[, context])
Description

Get {key: value} entry where map.key is the ith smallest key where i == index.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

indexinteger

Zero-based position, 0 being the first element. A negative index counts back from the end.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Single result

Expression form
Performance

Requesting a RANK return type adds 𝓞(N), or 𝓞(log N) with a persisted full index. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3} (K_ORDERED)
try (RecordStream rs = session.query(key)
.bin("m").onMapIndex(0).getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {a: 1} (smallest key by index)
}
try (RecordStream rs = session.query(key)
.bin("m").onMapIndex(-1).getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {c: 3} (largest key by index)
}

get_by_key_interval

get_by_key_range(bin_name, key_begin, key_end, result_type[, context])
Description

Get all {key: value} pairs where map.key >= keyStart and map.key < keyStop. Omitting keyStop select element(s) where map.key >= keyStart.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

key_beginany

Lowest key to match, inclusive.

key_endany

Upper bound on the key, exclusive. Omit it to match everything from key_begin upward.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Expression form
Performance

Requesting a RANK return type adds 𝓞(N log N). Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5}
try (RecordStream rs = session.query(key)
.bin("m").onMapKeyRange("b", "d").getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {b: 2, c: 3} (keys >= "b" and < "d")
}

get_by_key_rel_index_range

get_by_key_rel_index_range(bin_name, key, index[, count], result_type[, context])
Description

Get all {key: value} pairs where origin = index(key), k = indexof(map.key) and k >= origin + index and k < origin + index + count. Omitting count select element(s) where k >= origin + index.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

keyany

Key that index is measured from. It need not be present in the map — the index is taken from where it would sort.

indexinteger

Zero-based position, 0 being the first element. A negative index counts back from the end.

countinteger

Number of elements to select. Optional; defaults to the rest of the collection.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5} (K_ORDERED)
// Starting from key "b" (index 1), offset 0, count 3
try (RecordStream rs = session.query(key)
.bin("m").onMapKeyRelativeIndexRange("b", 0, 3).getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {b: 2, c: 3, d: 4}
}

get_by_key

get_by_key(bin_name, key, result_type[, context])
Description

Get entry {key: value} where map.key == key.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

keyany

Map key to match.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Single result

Expression form
Performance

Requesting an INDEX return type adds 𝓞(N), or 𝓞(log N) with a persisted index. Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3}
try (RecordStream rs = session.query(key)
.bin("m").onMapKey("b").getValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns 2
}

get_by_rank_range

get_by_rank_range(bin_name, rank[, count], result_type[, context])
Description

Get all {key: value} pairs where r = rankof(map.value) and r >= rank and r < rank + count. Omitting count select element(s) where r >= rank.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

rankinteger

Zero-based rank in value order, 0 being the smallest. A negative rank counts back from the largest.

countinteger

Number of elements to select. Optional; defaults to the rest of the collection.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Performance

Requesting an INDEX return type adds 𝓞(N log N) on an unordered map, or 𝓞(M) on a map with a persisted offset index. Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 3, b: 1, c: 5, d: 2, e: 4}
try (RecordStream rs = session.query(key)
.bin("m").onMapRankRange(0, 2).getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {b: 1, d: 2} (2 entries with lowest values)
}

get_by_rank

get_by_rank(bin_name, rank, result_type[, context])
Description

Get {key: value} entry where map.value is the ith smallest value where i == rank.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

rankinteger

Zero-based rank in value order, 0 being the smallest. A negative rank counts back from the largest.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Single result

Expression form
Performance

Requesting an INDEX return type adds 𝓞(N) on an unordered map, or 𝓞(1) on a map with a persisted offset index. Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 3, b: 1, c: 2}
try (RecordStream rs = session.query(key)
.bin("m").onMapRank(0).getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {b: 1} (smallest value)
}
try (RecordStream rs = session.query(key)
.bin("m").onMapRank(-1).getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {a: 3} (largest value)
}

get_by_value_interval

get_by_value_range(bin_name, value_begin, value_end, result_type[, context])
Description

Get all {key: value} pairs where map.value >= valueStart and map.value < valueStop. Omitting valueStop select element(s) where map.value >= valueStart.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

value_beginany

Lowest value to match, inclusive.

value_endany

Upper bound on the value, exclusive. Omit it to match everything from value_begin upward.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Expression form
Performance

Requesting an INDEX return type adds 𝓞(N + M) on an unordered map, or 𝓞(M) on a map with a persisted offset index. Requesting an ORDERED_MAP return type on an unordered map adds extra ordering cost relative to the number of elements in the result set. See Map performance.

Code sample
// m = {a: 1, b: 2, c: 3, d: 4, e: 5}
try (RecordStream rs = session.query(key)
.bin("m").onMapValueRange(2, 4).getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {b: 2, c: 3} (values >= 2 and < 4)
}

get_by_value_rel_rank_range

get_by_value_rel_rank_range(bin_name, value, rank[, count], result_type[, context])
Description

Get all {key: value} pairs where origin = rank(value), r = rankof(map.value) and r >= origin + rank and r < origin + rank + count. Omitting count select element(s) where r >= origin + rank.

Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

valueany

Value that rank is measured from. It need not be present in the collection — the rank is taken from where it would sort.

rankinteger

Zero-based rank in value order, 0 being the smallest. A negative rank counts back from the largest.

countinteger

Number of elements to select. Optional; defaults to the rest of the collection.

result_typeinteger literal

Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Multi result

Code sample
// m = {a: 11, b: 22, c: 33, d: 44, e: 55}
// Relative to value 30 (rank would be between b:22 and c:33), offset 0, count 2
try (RecordStream rs = session.query(key)
.bin("m").onMapValueRelativeRankRange(30, 0, 2).getKeysAndValues()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns {c: 33, d: 44}
}

size

size(bin_name[, context])
Arguments
NameTypeDescription
bin_namestring

Name of the bin to operate on.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

Element count

Expression form
Code sample
// m = {a: 1, b: 2, c: 3}
try (RecordStream rs = session.query(key)
.bin("m").mapSize()
.execute()) {
Record rec = rs.next().recordOrThrow();
// returns 3
}

Set operations

set_type

set_map_policy(policy, bin_name[, context])
Description

Modifies the order of an existing map. Order can be UNORDERED, K_ORDERED, or KV_ORDERED

Arguments
NameTypeDescription
policyMap policy

Ordering and write flags for the operation. See Write flags. The ordering attribute takes effect only when this operation creates the map; on a map that already exists it is ignored.

bin_namestring

Name of the bin to operate on.

contextContext instance

Optional context path from the bin to a nested List or Map, one selector per nesting level. Omit it to operate on the top level of the map.

Returns

null

Performance

The worst-case performance of modifying an unordered map to a K_ORDERED or KV_ORDERED one is 𝓞(N log N).

Code sample
// m = {a: 1, b: 2, c: 3} (UNORDERED)
try (RecordStream rs = session.upsert(key)
.bin("m").mapSetPolicy(MapOrder.KEY_ORDERED)
.execute()) {
Record rec = rs.next().recordOrThrow();
}
// m is now K_ORDERED