Skip to content

Map bin operations

For the complete documentation index see: llms.txt

All documentation pages available in markdown.

Aerospike map bin expressions read and modify map-type bins inside filter, operation, and projection pipelines. Use them with comparison and logic expressions when you need a Boolean filter, or compose them with record storage typed-bin readers (bin_map) when you need the map value first.

Map operations that read stored data evaluate to unknown when the underlying bin or key is missing, the type does not match, or the value is not yet available during the metadata-only phase of filter evaluation. See Record storage and the expressions overview execution model.

In each operation, the map operand (map_bin_expr in the argument tables) is any map-valued expression: not only a named map bin, but also the result of another expression that evaluates to a map. Map operations compose by passing those values as the map input—for example, taking the size of a map after a put. For nested collection data and path filters, see Querying collection data types and Path expressions.

This reference covers read operations (size, get-by-key, get-by-value, index and rank variants, ranges, and the map_keys/map_values extraction helpers) and modify operations (put, put_items, increment, clear, and remove_by_* variants). Map modify expressions evaluate on a temporary map value; they do not persist unless used in a write operation that stores the result. Map operations change the copy of the map bin in place.

Composing expressions

The map_put reference includes an example that wraps MapExp.put in MapExp.size—the same modify-then-read pattern described above. Many other modify operations show similar composition: their examples nest another map expression as the map operand (map_bin_expr in the arguments table).

Extraction helpers

The map_keys and map_values expressions (server 8.1.2+) are on the Exp class, not MapExp. They take a single map-valued expression and return a list—no context or return_type parameter. Use them to convert a map to a list of its keys or values for further expression processing, for example with in_list.

Modify

map_clear

map_clear(context, bin)
Description

Clear all elements in map bin.

Arguments
NameType
context library_specific
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using an empty map after map_clear.

import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(Exp.eq(MapExp.size(MapExp.clear(Exp.mapBin("stock"))), Exp.val(0)));

map_increment

map_increment(context, policy, key, delta, bin)
Description

Increment element at key by delta.

Arguments
NameType
context library_specific
policy library_specific
key expr
delta integer_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the value at sku-a after incrementing it by 5.

import com.aerospike.client.cdt.MapPolicy;
import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.eq(
MapExp.getByKey(
MapReturnType.VALUE,
Exp.Type.INT,
Exp.val("sku-a"),
MapExp.increment(MapPolicy.Default, Exp.val("sku-a"), Exp.val(5), Exp.mapBin("stock"))),
Exp.val(100)));

map_put

map_put(context, policy, key, value, bin)
Description

Add {key, value} element to bin. map_put does not create a new bin if the specified bin does not exist, unlike the put CDT Map operation, which does create a new bin if the specified bin does not exist.

Arguments
NameType
context library_specific
policy library_specific
key expr
value expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map after putting {sku-a: 12} into stock.

import com.aerospike.client.cdt.MapPolicy;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(MapExp.put(MapPolicy.Default, Exp.val("sku-a"), Exp.val(12), Exp.mapBin("stock"))),
Exp.val(2)));

map_put_items

map_put_items(context, policy, items, bin)
Description

Add elements in items to bin. map_put_items does not create a new bin if the specified bin does not exist, unlike the put_items CDT Map operation, which does create a new bin if the specified bin does not exist.

Arguments
NameType
context library_specific
policy library_specific
items map_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map after merging additional SKU entries into stock.

import com.aerospike.client.cdt.MapPolicy;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(
MapExp.putItems(
MapPolicy.Default,
Exp.val(java.util.Map.of("sku-b", 2, "sku-c", 3)),
Exp.mapBin("stock"))),
Exp.val(3)));

map_remove_by_index

map_remove_by_index(context, index, bin)
Description

Remove element at index.

Arguments
NameType
context library_specific
index integer_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after removing index 0.

import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(MapExp.size(MapExp.removeByIndex(Exp.val(0), Exp.mapBin("stock"))), Exp.val(0)));

map_remove_by_index_range

map_remove_by_index_range(context, index, count, bin)
Description

Remove count element at index.

Arguments
NameType
context library_specific
index integer_expr
count integer_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after removing one entry at index 0.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(
MapExp.removeByIndexRange(MapReturnType.NONE, Exp.val(0), Exp.val(1), Exp.mapBin("stock"))),
Exp.val(0)));

map_remove_by_index_range_to_end

map_remove_by_index_range_to_end(context, index, bin)
Description

Remove all element at and after index.

Arguments
NameType
context library_specific
index integer_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after removing from index 1 to the end.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(MapExp.removeByIndexRange(MapReturnType.NONE, Exp.val(1), Exp.mapBin("stock"))),
Exp.val(0)));

map_remove_by_key

map_remove_by_key(context, key, bin)
Description

Remove element with key key.

Arguments
NameType
context library_specific
key expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after removing key sku-a.

import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.eq(MapExp.size(MapExp.removeByKey(Exp.val("sku-a"), Exp.mapBin("stock"))), Exp.val(2)));

map_remove_by_key_list

map_remove_by_key_list(context, keys, bin)
Description

Remove all elements where key ∈ keys.

Arguments
NameType
context library_specific
keys list_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after removing two keys.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
import java.util.Arrays;
Expression exp = Exp.build(
Exp.eq(
MapExp.size(
MapExp.removeByKeyList(
MapReturnType.NONE,
Exp.val(Arrays.asList("sku-a", "sku-b")),
Exp.mapBin("stock"))),
Exp.val(1)));

map_remove_by_key_range

map_remove_by_key_range(context, start, end, bin)
Description

Remove all elements with key k in interval start ≤ k < end.

Arguments
NameType
context library_specific
start expr
end expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after removing a key interval.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(
MapExp.removeByKeyRange(
MapReturnType.NONE, Exp.val("sku-a"), Exp.val("sku-z"), Exp.mapBin("stock"))),
Exp.val(0)));

map_remove_by_rank

map_remove_by_rank(context, rank, bin)
Description

Remove all element with rank rank.

Arguments
NameType
context library_specific
rank integer_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after removing rank 0.

import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(MapExp.size(MapExp.removeByRank(Exp.val(0), Exp.mapBin("stock"))), Exp.val(0)));

map_remove_by_rank_range

map_remove_by_rank_range(context, rank, count, bin)
Description

Remove count element at rank.

Arguments
NameType
context library_specific
rank integer_expr
count integer_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after removing two ranks starting at 0.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(
MapExp.removeByRankRange(MapReturnType.NONE, Exp.val(0), Exp.val(2), Exp.mapBin("stock"))),
Exp.val(0)));

map_remove_by_rank_range_to_end

map_remove_by_rank_range_to_end(context, rank, bin)
Description

Remove all elements at and after rank.

Arguments
NameType
context library_specific
rank integer_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after removing from rank 0 to the last rank.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(MapExp.removeByRankRange(MapReturnType.NONE, Exp.val(0), Exp.mapBin("stock"))),
Exp.val(0)));

map_remove_by_rel_index_range

map_remove_by_rel_index_range(context, key, index, count, bin)
Description

Remove count elements at index relative to key.

Arguments
NameType
context library_specific
key expr
index integer_expr
count integer_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after a key-relative index remove with count.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(
MapExp.removeByKeyRelativeIndexRange(
MapReturnType.NONE, Exp.val("sku-a"), Exp.val(0), Exp.val(1), Exp.mapBin("stock"))),
Exp.val(0)));

map_remove_by_rel_index_range_to_end

map_remove_by_rel_index_range_to_end(context, key, index, bin)
Description

Remove all elements at and after index relative to key.

Arguments
NameType
context library_specific
key expr
index integer_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after a key-relative index remove to end.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(
MapExp.removeByKeyRelativeIndexRange(
MapReturnType.NONE, Exp.val("sku-a"), Exp.val(0), Exp.mapBin("stock"))),
Exp.val(0)));

map_remove_by_rel_rank_range

map_remove_by_rel_rank_range(context, value, rank, count, bin)
Description

Remove count elements at rank relative to value.

Arguments
NameType
context library_specific
value expr
rank integer_expr
count integer_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after a value-relative rank remove with count.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(
MapExp.removeByValueRelativeRankRange(
MapReturnType.NONE, Exp.val(5), Exp.val(0), Exp.val(2), Exp.mapBin("stock"))),
Exp.val(0)));

map_remove_by_rel_rank_range_to_end

map_remove_by_rel_rank_range_to_end(context, value, rank, bin)
Description

Remove all elements at and after rank relative to value.

Arguments
NameType
context library_specific
value expr
rank integer_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after a value-relative rank remove to end.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(
MapExp.removeByValueRelativeRankRange(MapReturnType.NONE, Exp.val(5), Exp.val(0), Exp.mapBin("stock"))),
Exp.val(0)));

map_remove_by_value

map_remove_by_value(context, value, bin)
Description

Remove all element with value value.

Arguments
NameType
context library_specific
value expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after removing by value 12.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(MapExp.size(MapExp.removeByValue(MapReturnType.NONE, Exp.val(12), Exp.mapBin("stock"))), Exp.val(0)));

map_remove_by_value_list

map_remove_by_value_list(context, values, bin)
Description

Remove all elements where value ∈ values.

Arguments
NameType
context library_specific
values list_expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after removing by values 5 and 12.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
import java.util.Arrays;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(
MapExp.removeByValueList(MapReturnType.NONE, Exp.val(Arrays.asList(5, 12)), Exp.mapBin("stock"))),
Exp.val(0)));

map_remove_by_value_range

map_remove_by_value_range(context, start, end, bin)
Description

Remove all elements with value v in interval start ≤ v < end.

Arguments
NameType
context library_specific
start expr
end expr
bin map_bin_expr
Returns
map_bin
Introduced
5.2.0.4
Example

Hypothetical filter using the map size after removing values in [5, 20).

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.size(
MapExp.removeByValueRange(MapReturnType.NONE, Exp.val(5), Exp.val(20), Exp.mapBin("stock"))),
Exp.val(0)));

Read

map_get_by_index

map_get_by_index(type, context, result_type, index, bin)
Description

Get element at index.

Arguments
NameType
type integer_value
context library_specific
result_type integer_value
index integer_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where the integer value at map index 0 equals 12.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.eq(
MapExp.getByIndex(MapReturnType.VALUE, Exp.Type.INT, Exp.val(0), Exp.mapBin("stock")),
Exp.val(12)));

map_get_by_index_range

map_get_by_index_range(context, result_type, index, count, bin)
Description

Get count elements at index.

Arguments
NameType
context library_specific
result_type integer_value
index integer_expr
count integer_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where two entries exist starting at map index 0.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.eq(
MapExp.getByIndexRange(MapReturnType.COUNT, Exp.val(0), Exp.val(2), Exp.mapBin("stock")),
Exp.val(2)));

map_get_by_index_range_to_end

map_get_by_index_range_to_end(context, result_type, index, bin)
Description

Get elements at and after index.

Arguments
NameType
context library_specific
result_type integer_value
index integer_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where the count from index 1 to the end is positive.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(MapExp.getByIndexRange(MapReturnType.COUNT, Exp.val(1), Exp.mapBin("stock")), Exp.val(0)));

map_get_by_key

map_get_by_key(type, context, result_type, key, bin)
Description

Get element with key == key.

Arguments
NameType
type integer_value
context library_specific
result_type integer_value
key expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where the integer value at key sku-a in stock equals 12.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.eq(
MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, Exp.val("sku-a"), Exp.mapBin("stock")),
Exp.val(12)));

map_get_by_key_list

map_get_by_key_list(context, result_type, keys, bin)
Description

Get all elements where key ∈ keys.

Arguments
NameType
context library_specific
result_type integer_value
keys list_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where the map has positive COUNT for keys sku-a and sku-b in stock.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
import java.util.Arrays;
Expression exp = Exp.build(
Exp.gt(
MapExp.getByKeyList(
MapReturnType.COUNT, Exp.val(Arrays.asList("sku-a", "sku-b")), Exp.mapBin("stock")),
Exp.val(0)));

map_get_by_key_range

map_get_by_key_range(context, result_type, start, end, bin)
Description

Get all elements with key k in interval start ≤ k < end.

Arguments
NameType
context library_specific
result_type integer_value
start expr
end expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where the count of map entries with keys less than sku-z is positive.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.getByKeyRange(MapReturnType.COUNT, Exp.val((String) null), Exp.val("sku-z"), Exp.mapBin("stock")),
Exp.val(0)));

map_get_by_rank

map_get_by_rank(type, context, result_type, rank, bin)
Description

Get element at rank.

Arguments
NameType
type integer_value
context library_specific
result_type integer_value
rank integer_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where the lowest-ranked value equals 5.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.eq(
MapExp.getByRank(MapReturnType.VALUE, Exp.Type.INT, Exp.val(0), Exp.mapBin("stock")),
Exp.val(5)));

map_get_by_rank_range

map_get_by_rank_range(context, result_type, rank, count, bin)
Description

Get count element at rank.

Arguments
NameType
context library_specific
result_type integer_value
rank integer_expr
count integer_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where exactly two entries are selected starting at rank 0.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.eq(
MapExp.getByRankRange(MapReturnType.COUNT, Exp.val(0), Exp.val(2), Exp.mapBin("stock")),
Exp.val(2)));

map_get_by_rank_range_to_end

map_get_by_rank_range_to_end(context, result_type, rank, bin)
Description

Get all elements at and after rank.

Arguments
NameType
context library_specific
result_type integer_value
rank integer_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where the count from rank 0 to the last rank is positive.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(MapExp.getByRankRange(MapReturnType.COUNT, Exp.val(0), Exp.mapBin("stock")), Exp.val(0)));

map_get_by_rel_index_range

map_get_by_rel_index_range(context, result_type, key, index, count_expr, bin)
Description

Get count elements at index relative to key.

Arguments
NameType
context library_specific
result_type integer_value
key expr
index integer_expr
count_expr integer_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where exactly one entry is selected starting at index 0 relative to key sku-a.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.eq(
MapExp.getByKeyRelativeIndexRange(
MapReturnType.COUNT, Exp.val("sku-a"), Exp.val(0), Exp.val(1), Exp.mapBin("stock")),
Exp.val(1)));

map_get_by_rel_index_range_to_end

map_get_by_rel_index_range_to_end(context, result_type, key, index_expr, bin)
Description

Get all elements at and after index relative to key.

Arguments
NameType
context library_specific
result_type integer_value
key expr
index_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where the COUNT of entries from index 0 relative to key sku-a is positive.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.getByKeyRelativeIndexRange(
MapReturnType.COUNT, Exp.val("sku-a"), Exp.val(0), Exp.mapBin("stock")),
Exp.val(0)));

map_get_by_rel_rank_range

map_get_by_rel_rank_range(context, result_type, value, rank, count, bin)
Description

Get count elements at rank relative to value.

Arguments
NameType
context library_specific
result_type integer_value
value expr
rank integer_expr
count integer_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where bounded relative-rank selection from value 5 has positive COUNT.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.getByValueRelativeRankRange(
MapReturnType.COUNT, Exp.val(5), Exp.val(0), Exp.val(2), Exp.mapBin("stock")),
Exp.val(0)));

map_get_by_rel_rank_range_to_end

map_get_by_rel_rank_range_to_end(context, result_type, value, rank, bin)
Description

Get all elements at and after rank relative to value.

Arguments
NameType
context library_specific
result_type integer_value
value expr
rank integer_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where relative rank selection from value 5 has positive COUNT.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.getByValueRelativeRankRange(
MapReturnType.COUNT, Exp.val(5), Exp.val(0), Exp.mapBin("stock")),
Exp.val(0)));

map_get_by_value

map_get_by_value(context, result_type, value, bin)
Description

Get all elements where value == value.

Arguments
NameType
context library_specific
result_type integer_value
value expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where the count of map entries with value 12 is positive.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(MapExp.getByValue(MapReturnType.COUNT, Exp.val(12), Exp.mapBin("stock")), Exp.val(0)));

map_get_by_value_list

map_get_by_value_list(context, result_type, values, bin)
Description

Get all elements where value ∈ values.

Arguments
NameType
context library_specific
result_type integer_value
values list_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where the count of entries with values 5 and 12 is positive.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
import java.util.Arrays;
Expression exp = Exp.build(
Exp.gt(
MapExp.getByValueList(MapReturnType.COUNT, Exp.val(Arrays.asList(5, 12)), Exp.mapBin("stock")),
Exp.val(0)));

map_get_by_value_range

map_get_by_value_range(context, result_type, start, end, bin)
Description

Get all elements with value v in interval start ≤ v < end.

Arguments
NameType
context library_specific
result_type integer_value
start integer_expr
end integer_expr
bin map_bin_expr
Introduced
5.2.0.4
Example

Filter where the count of values in [5, 50) in stock is positive.

import com.aerospike.client.cdt.MapReturnType;
import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(
MapExp.getByValueRange(MapReturnType.COUNT, Exp.val(5), Exp.val(50), Exp.mapBin("stock")),
Exp.val(0)));

map_keys

map_keys(bin)
Description

Extract all keys from a map as a list. Unlike the MapExp / CDT map read operations, this is a standalone expression (Exp class) that takes no context or return_type parameter.

Arguments
NameType
bin map_bin_expr
Returns
list_value
Introduced
8.1.2
Example

Get the keys of map bin stock as a list, then check its list_size is greater than 0.

import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.ListExp;
Expression exp = Exp.build(
Exp.gt(
ListExp.size(Exp.mapKeysIn(Exp.mapBin("stock"))),
Exp.val(0)));

map_size

map_size(context, bin)
Description

Get number of items in the map.

Arguments
NameType
context library_specific
bin map_bin_expr
Returns
integer_bin
Introduced
5.2.0.4
Example

Filter records whose map bin stock is non-empty (same pattern as bin_map with size).

import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build(
Exp.gt(MapExp.size(Exp.mapBin("stock")), Exp.val(0)));

map_values

map_values(bin)
Description

Extract all values from a map as a list. Unlike the MapExp / CDT map read operations, this is a standalone expression (Exp class) that takes no context or return_type parameter.

Arguments
NameType
bin map_bin_expr
Returns
list_value
Introduced
8.1.2
Example

Get the values of map bin stock as a list, then check its list_size is greater than 0.

import com.aerospike.client.exp.Expression;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.exp.ListExp;
Expression exp = Exp.build(
Exp.gt(
ListExp.size(Exp.mapValuesIn(Exp.mapBin("stock"))),
Exp.val(0)));
Feedback

Was this page helpful?

What type of feedback are you giving?

What would you like us to know?

+Capture screenshot

Can we reach out to you?