List operations
For the complete documentation index see: llms.txt
All documentation pages available in markdown.
List operations read, update, and remove elements in list-type bins directly on the server.
These operations have expression counterparts, which evaluate to a value instead of writing it. See List expressions for the set, and Operations and expressions for which to reach for.
List policy
The list policy defines the order and write behavior for a list.
List order
The list order is set in the list policy and determines the list subtype:
- Unordered (default) - maintains insertion order. New elements are appended to the end.
- Ordered - maintains sorted (rank) order. Elements are sorted on each write.
Use set_order() to convert between order types.
See List performance for the operational complexity of each order type.
Persisting the list index
For large ordered lists with a high read-to-write ratio, rebuilding the offset index
on every access can consume significant CPU. Setting persistIndex to true in
set_order() or create()
stores the offset index on disk alongside the list itself, so subsequent
operations load it directly instead of rebuilding it.
Once set, both the order and persist-index flags are preserved across all subsequent
list operations (append, insert, remove, etc.) until changed by another set_order() call.
The persist-index flag applies only to top-level lists. For nested lists the flag is silently ignored.
See column (3) in the List performance table for the performance impact.
Write flags
| Flag | Description |
|---|---|
MODIFY_DEFAULT | Default: not bound by list size; accepts duplicate elements; throws error on failure |
ADD_UNIQUE | Only add elements if they do not already exist in the list |
INSERT_BOUNDED | Do not insert past index N, where N is the element count |
NO_FAIL | No-op instead of fail if a policy violation occurred, such as ADD_UNIQUE or INSERT_BOUNDED |
DO_PARTIAL | When used with NO_FAIL, add elements that did not violate a policy |
Write flags can be combined using bitwise OR. For example, ADD_UNIQUE | NO_FAIL | DO_PARTIAL
adds only unique elements, skips duplicates without failing, and commits the non-duplicate elements.
Context
| Context Type | Description |
|---|---|
LIST_INDEX | Finds an element in a List by index. A negative index is a lookup performed in reverse from the end of the list. If it is out of bounds, a parameter error is returned. |
LIST_RANK | Finds an element in a List by rank. A negative rank is a lookup performed in reverse from the highest ranked. |
LIST_VALUE | Finds an element in a List by value. |
LIST_INDEX_CREATE | Finds an element in a List by index. Creates the element if it does not exist. |
The context is a list of element selectors describing a path to the nested list element where the operation should be applied. Without a context it is assumed that the operation occurs at the top level of the list.
Return types
| Return Type | Description |
|---|---|
VALUE | The value of the element (in single result operations) or elements (in multi result operations) |
NONE | Nothing is returned. It speeds up remove operations by not constructing a reply |
COUNT | Number of elements returned |
INDEX | Index position of the element, from 0 (first) to N-1 (last) |
REVERSE_INDEX | Reverse index position of the element, from 0 (last) to N-1 (first) |
RANK | Value order of the element, with 0 being the smallest |
REVERSE_RANK | Reverse rank order of the element, with 0 being the largest value |
INVERTED | Invert meaning of list command and return values. Combine with another return type using bitwise OR, such as `COUNT |
EXISTS | Returns 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 list. |
Examples
- Remove the last 3 elements:
remove_by_index_range(-3, 3, NONE) - Remove all but the last 3 elements:
remove_by_index_range(-3, 3, NONE | INVERTED) - Keep only the last 3 elements and return the count of removed elements:
remove_by_index_range(-3, 3, COUNT | INVERTED)
Availability
EXISTS available since 6.1.0.
Modify operations
append_items(policy, bin_name, items[, context])Creates a list bin with a specified order, if the bin does not exist. Adds the items to the list. In an UNORDERED list the items are appended to the end of the list. In an ORDERED list the items are inserted by value order.
| Name | Type | Description |
|---|---|---|
policy | List policy | Ordering and write flags for the operation. See Write flags. The ordering attribute takes effect only when this operation creates the list; on a list that already exists it is ignored. |
bin_name | string | Name of the bin to operate on. |
items | list | Elements to append, as a list. |
context | Context 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 list. |
The element count due to the operation, in the ‘bins’ part of the record under the bin name.
A list newly created with append_items can be declared UNORDERED (default) or ORDERED using the list order attribute of the list policy. Once a list is created its order can only be modified with set_order.
The worst-case performance of append_items on an unordered list is 𝓞(M), and 𝓞((M+N) log (M+N)) on an ordered list, where M is the number of items to append and N is the number of items already in the list.
// scores = [10, 20, 30]
try (RecordStream rs = session.upsert(key) .bin("scores").listAppendItems(List.of(40, 50)) .execute()) { Record rec = rs.next().recordOrThrow(); // returns 5 (new list size)}// scores == [10, 20, 30, 40, 50]# scores = [10, 20, 30]
stream = session.upsert(key).bin("scores").list_append_items([40, 50]).execute()# returns 5 (new list size)# scores == [10, 20, 30, 40, 50]// Requires: use aerospike::operations::lists::{self, ListPolicy};// scores = [10, 20, 30]
let record = client.operate(&WritePolicy::default(), &key, &[lists::append_items(&ListPolicy::default(), "scores", as_values!(40, 50))]).await?;// returns 5 (new list size)// scores == [10, 20, 30, 40, 50]// scores = [10, 20, 30]
IList newItems = new List<Value> { Value.Get(40), Value.Get(50) };
Record record = client.Operate(null, key, ListOperation.AppendItems("scores", newItems));// returns 5 (new list size)// scores == [10, 20, 30, 40, 50]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// scores = [10, 20, 30]
record, err := client.Operate(nil, key, as.ListAppendOp("scores", 40, 50),)// record.Bins["scores"] == 5// scores == [10, 20, 30, 40, 50]// scores = [10, 20, 30]
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.appendItems('scores', [40, 50])])// result.bins.scores == 5// scores == [10, 20, 30, 40, 50]// scores = [10, 20, 30]
as_arraylist items;as_arraylist_inita(&items, 2);as_arraylist_append_int64(&items, 40);as_arraylist_append_int64(&items, 50);
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_append_items(&ops, "scores", NULL, NULL, (as_list*)&items);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "scores" == 5// scores == [10, 20, 30, 40, 50]// scores = [10, 20, 30]
List<Value> newItems = Arrays.asList(Value.get(40), Value.get(50));
Record record = client.operate(null, key, ListOperation.appendItems("scores", newItems));// returns 5 (new list size)// scores == [10, 20, 30, 40, 50]# scores = [10, 20, 30]
_, _, bins = client.operate(key, [ list_operations.list_append_items("scores", [40, 50])])# bins["scores"] == 5 (new list size)# scores == [10, 20, 30, 40, 50]append(policy, bin_name, value[, context])Creates a list bin with a specified order, if the bin does not exist. Adds a value to the list. In an UNORDERED list the value is appended to the end of the list. In an ORDERED list the value is inserted by value order.
| Name | Type | Description |
|---|---|---|
policy | List policy | Ordering and write flags for the operation. See Write flags. The ordering attribute takes effect only when this operation creates the list; on a list that already exists it is ignored. |
bin_name | string | Name of the bin to operate on. |
value | any | Element to append to the list. |
context | Context 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 list. |
The element count due to the operation, in the ‘bins’ part of the record under the bin name.
A list newly created with append can be declared UNORDERED (default) or ORDERED using the list order attribute of the list policy. Once a list is created its order can only be modified with set_order.
The worst-case performance of append() on an unordered list is 𝓞(N).
// scores = [10, 20, 30]
try (RecordStream rs = session.upsert(key) .bin("scores").listAppend(40) .execute()) { Record rec = rs.next().recordOrThrow(); // returns 4 (new list size)}// scores == [10, 20, 30, 40]# scores = [10, 20, 30]
stream = session.upsert(key).bin("scores").list_append(40).execute()# returns 4 (new list size)# scores == [10, 20, 30, 40]// Requires: use aerospike::operations::lists::{self, ListPolicy};// scores = [10, 20, 30]
let record = client.operate(&WritePolicy::default(), &key, &[lists::append(&ListPolicy::default(), "scores", as_val!(40))]).await?;// returns 4 (new list size)// scores == [10, 20, 30, 40]// scores = [10, 20, 30]
Record record = client.Operate(null, key, ListOperation.Append("scores", Value.Get(40)));// returns 4 (new list size)// scores == [10, 20, 30, 40]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// scores = [10, 20, 30]
record, err := client.Operate(nil, key, as.ListAppendOp("scores", 40),)// record.Bins["scores"] == 4// scores == [10, 20, 30, 40]// scores = [10, 20, 30]
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.append('scores', 40)])// result.bins.scores == 4// scores == [10, 20, 30, 40]// scores = [10, 20, 30]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_append(&ops, "scores", NULL, NULL, (as_val*)as_integer_new(40));
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "scores" == 4 (new list size)// scores == [10, 20, 30, 40]// scores = [10, 20, 30]
Record record = client.operate(null, key, ListOperation.append("scores", Value.get(40)));// returns 4 (new list size)// scores == [10, 20, 30, 40]# scores = [10, 20, 30]
_, _, bins = client.operate(key, [ list_operations.list_append("scores", 40)])# bins["scores"] == 4 (new list size)# scores == [10, 20, 30, 40]clear(bin_name[, context])Clears a list, optionally at a given subcontext.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
context | Context 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 list. |
null
The worst-case performance of clearing a list is 𝓞(1).
// scores = [10, 20, 30, 40, 50]
try (RecordStream rs = session.upsert(key) .bin("scores").listClear() .execute()) { Record rec = rs.next().recordOrThrow();}// scores == []# scores = [10, 20, 30, 40, 50]
session.upsert(key).bin("scores").list_clear().execute()# scores == []// Requires: use aerospike::operations::lists::{self};// scores = [10, 20, 30, 40, 50]
client.operate(&WritePolicy::default(), &key, &[lists::clear("scores")]).await?;// scores == []// scores = [10, 20, 30, 40, 50]
client.Operate(null, key, ListOperation.Clear("scores"));// scores == []// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// scores = [10, 20, 30, 40, 50]
_, err := client.Operate(nil, key, as.ListClearOp("scores"),)// scores == []// scores = [10, 20, 30, 40, 50]
const lists = Aerospike.lists
await client.operate(key, [ lists.clear('scores')])// scores == []// scores = [10, 20, 30, 40, 50]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_clear(&ops, "scores", NULL);
aerospike_key_operate(&as, &err, NULL, &key, &ops, NULL);// scores == []// scores = [10, 20, 30, 40, 50]
client.operate(null, key, ListOperation.clear("scores"));// scores == []# scores = [10, 20, 30, 40, 50]
client.operate(key, [ list_operations.list_clear("scores")])# scores == []increment(policy, bin_name, index, delta[, context])Creates an unordered list bin if the bin does not exist. In an UNORDERED list, increment() initializes or increments a numeric value at the specified list index. In an ORDERED list, increments a numeric value at a specific rank, given by the index argument.
By default the index can be any number, and NIL values will be added as padding to the left of the new element, as needed. Using the INSERT_BOUNDED policy, a developer can limit this behavior, and only allow for an element to be incremented at an index value between 0 and the size of the list.
Increment delta values can be either float or integer. An integer delta value will be converted into a float if the server-side type is a float. A float delta-value will be converted and truncated into an integer if the server-side value is an integer.
| Name | Type | Description |
|---|---|---|
policy | List policy | Ordering and write flags for the operation. See Write flags. The ordering attribute takes effect only when this operation creates the list; on a list that already exists it is ignored. |
bin_name | string | Name of the bin to operate on. |
index | integer | Zero-based position of the element to increment. |
delta | integer or float | Amount to add. A negative value subtracts. |
context | Context 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 list. |
The new value after the increment, in the ‘bins’ part of the record under the bin name.
A list newly created with increment is always unordered. Once a list is created its order can only be modified with set_order.
The worst-case performance of increment() on an unordered list is 𝓞(N).
// scores = [10, 20, 30]
try (RecordStream rs = session.upsert(key) .bin("scores").listIncrement(1, 5) .execute()) { Record rec = rs.next().recordOrThrow(); // returns 25 (new value at index 1)}// scores == [10, 25, 30]# scores = [10, 20, 30]
stream = session.upsert(key).bin("scores").list_increment(1, 5).execute()# returns 25 (new value at index 1)# scores == [10, 25, 30]// Requires: use aerospike::operations::lists::{self, ListPolicy};// scores = [10, 20, 30]
let record = client.operate(&WritePolicy::default(), &key, &[lists::increment(&ListPolicy::default(), "scores", 1, 5)]).await?;// returns 25 (new value at index 1)// scores == [10, 25, 30]// scores = [10, 20, 30]
Record record = client.Operate(null, key, ListOperation.Increment("scores", 1, Value.Get(5)));// returns 25// scores == [10, 25, 30]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// scores = [10, 20, 30]
record, err := client.Operate(nil, key, as.ListIncrementOp("scores", 1, 5),)// record.Bins["scores"] == 25// scores == [10, 25, 30]// scores = [10, 20, 30]
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.increment('scores', 1, 5)])// result.bins.scores == 25// scores == [10, 25, 30]// scores = [10, 20, 30]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_increment(&ops, "scores", NULL, NULL, 1, (as_val*)as_integer_new(5));
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "scores" == 25// scores == [10, 25, 30]// scores = [10, 20, 30]
Record record = client.operate(null, key, ListOperation.increment("scores", 1, Value.get(5)));// returns 25 (new value at index 1)// scores == [10, 25, 30]# scores = [10, 20, 30]
_, _, bins = client.operate(key, [ list_operations.list_increment("scores", 1, 5)])# bins["scores"] == 25# scores == [10, 25, 30]insert(policy, bin_name, index, value[, context])Creates an unordered list bin, if the bin does not exist. Inserts a value into the list at the specified index, and shifts elements with a higher index to the right of the new element.
By default the index can be any number, and NIL values will be added as padding to the left of the new element, as needed. Using the INSERT_BOUNDED policy, a developer can limit this behavior, and only allow for an element to be inserted at an index value between 0 and the size of the list.
you cannot insert into an ordered list, only append or append_items to one.
| Name | Type | Description |
|---|---|---|
policy | List policy | Ordering and write flags for the operation. See Write flags. The ordering attribute takes effect only when this operation creates the list; on a list that already exists it is ignored. |
bin_name | string | Name of the bin to operate on. |
index | integer | Zero-based position, 0 being the first element. A negative index counts back from the end. |
value | any | Element to insert at |
context | Context 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 list. |
The element count due to the operation, in the ‘bins’ part of the record under the bin name.
A list newly created with insert is always unordered. Once a list is created its order can only be modified with set_order.
The worst-case performance of inserting an item at the head of a list (at its 0th index) is 𝓞(1). At any other index it is 𝓞(N).
// scores = [10, 30, 40]
try (RecordStream rs = session.upsert(key) .bin("scores").listInsert(1, 20) .execute()) { Record rec = rs.next().recordOrThrow(); // returns 4 (new list size)}// scores == [10, 20, 30, 40]# scores = [10, 30, 40]
stream = session.upsert(key).bin("scores").list_insert(1, 20).execute()# returns 4 (new list size)# scores == [10, 20, 30, 40]// Requires: use aerospike::operations::lists::{self, ListPolicy};// scores = [10, 30, 40]
let record = client.operate(&WritePolicy::default(), &key, &[lists::insert(&ListPolicy::default(), "scores", 1, as_val!(20))]).await?;// returns 4 (new list size)// scores == [10, 20, 30, 40]// scores = [10, 30, 40]
Record record = client.Operate(null, key, ListOperation.Insert("scores", 1, Value.Get(20)));// returns 4 (new list size)// scores == [10, 20, 30, 40]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// scores = [10, 30, 40]
record, err := client.Operate(nil, key, as.ListInsertOp("scores", 1, 20),)// record.Bins["scores"] == 4// scores == [10, 20, 30, 40]// scores = [10, 30, 40]
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.insert('scores', 1, 20)])// result.bins.scores == 4// scores == [10, 20, 30, 40]// scores = [10, 30, 40]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_insert(&ops, "scores", NULL, NULL, 1, (as_val*)as_integer_new(20));
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "scores" == 4// scores == [10, 20, 30, 40]// scores = [10, 30, 40]
Record record = client.operate(null, key, ListOperation.insert("scores", 1, Value.get(20)));// returns 4 (new list size)// scores == [10, 20, 30, 40]# scores = [10, 30, 40]
_, _, bins = client.operate(key, [ list_operations.list_insert("scores", 1, 20)])# bins["scores"] == 4# scores == [10, 20, 30, 40]remove_by_value_list(bin_name, values, result_type[, context])Removes all the elements in the list matching one of the specified values. The INVERTED flag may be used to remove the elements not matching the specified values.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
values | list | Values to match, as a list. Every element equal to any of them is selected. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
Zero, one or a list of values, based on the return type. The NONE return type will execute faster because no reply is constructed for the operation. The elements returned by other return types may not be in index order.
Whether the list is unordered or ordered, remove_all_by_value_list will return the same elements, based on the ordering rules. The performance of ‘by value’ operations is better on an ordered list than an unordered one.
The worst-case performance of removing elements by a value list is 𝓞((M+N) log M) for an ordered list with a persisted index, 𝓞((M+N) log M + N) for an ordered list without a persisted index, or for an unordered list, where M is the number of items in the parameter list and N is the number of items already in the list.
Remove scalar values from the list matching one of several specified values. See the code sample below.
See the example given for remove_all_by_value.
In a list of mostly ordered pairs, we could remove all the tuples matching the patterns [v1, *] and [v2, *].
The wildcard matches any sequence of elements to the end of the tuple. In this example, this means matching any tuple whose first position is “v1” or “v2”, and whose size is two or more elements.
The wildcard has different language-specific constructs, such as aerospike.CDTWildcard() in the Python client and Value.WILDCARD in the Java client.
// Trivial example// l = [1, 2, 3, 4, 3, 2, 1]
try (RecordStream rs = session.upsert(key) .bin("l").onListValueList(List.of(2, 3)).removeAnd().count() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 4}// l == [1, 4, 1]
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4], ["v1", 5]]
try (RecordStream rs = session.upsert(key) .bin("l").onListValueList(List.of( List.of("v1", SpecialValue.WILDCARD), List.of("v2", SpecialValue.WILDCARD))).remove() .bin("l").get() .execute()) { Record rec = rs.next().recordOrThrow();}// l == [["v3", 3]]# Trivial example# l = [1, 2, 3, 4, 3, 2, 1]
stream = (session.upsert(key).bin("l").on_list_value_list([2, 3]) .remove(return_type=ListReturnType.COUNT).execute())# returns 4# l == [1, 4, 1]
# Matching tuples with wildcard# l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4], ["v1", 5]]
stream = (session.upsert(key).bin("l") .on_list_value_list([["v1", SpecialValue.WILDCARD], ["v2", SpecialValue.WILDCARD]]).remove() .bin("l").get().execute())# l == [["v3", 3]]// Requires: use aerospike::operations::{self, lists::{self, ListReturnType}};// Trivial example// l = [1, 2, 3, 4, 3, 2, 1]
let record = client.operate(&WritePolicy::default(), &key, &[lists::remove_by_value_list("l", as_values!(2, 3), ListReturnType::Count)]).await?;// returns 4// l == [1, 4, 1]
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4], ["v1", 5]]
let record = client.operate(&WritePolicy::default(), &key, &[lists::remove_by_value_list("l", vec![as_list!("v1", Value::Wildcard), as_list!("v2", Value::Wildcard)], ListReturnType::None), operations::get_bin("l")]).await?;// l == [["v3", 3]]// Trivial example// l = [1, 2, 3, 4, 3, 2, 1]
IList removeValues = new List<Value> { Value.Get(2), Value.Get(3)};
Record record = client.Operate(null, key, ListOperation.RemoveByValueList("l", removeValues, ListReturnType.COUNT));// returns 4// l == [1, 4, 1]
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4], ["v1", 5]]
IList patterns = new List<Value> { Value.Get(new List<Value> { Value.Get("v1"), Value.WILDCARD }), Value.Get(new List<Value> { Value.Get("v2"), Value.WILDCARD })};
record = client.Operate(null, key, ListOperation.RemoveByValueList("l", patterns, ListReturnType.NONE), Operation.Get("l"));// l == [["v3", 3]]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// Trivial example// l = [1, 2, 3, 4, 3, 2, 1]
record, err := client.Operate(nil, key, as.ListRemoveByValueListOp("l", []any{2, 3}, as.ListReturnTypeCount),)// record.Bins["l"] == 4// l == [1, 4, 1]
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4], ["v1", 5]]
record, err = client.Operate(nil, key, as.ListRemoveByValueListOp("l", []any{ []any{"v1", as.NewWildCardValue()}, []any{"v2", as.NewWildCardValue()}, }, as.ListReturnTypeNone), as.GetBinOp("l"),)// record.Bins["l"] == [["v3", 3]]// Trivial example// l = [1, 2, 3, 4, 3, 2, 1]
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.removeByValueList('l', [2, 3]).andReturn(lists.returnType.COUNT)])// result.bins.l == 4// l == [1, 4, 1]
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4], ["v1", 5]]
// The Node.js client cannot put a wildcard inside a list value, so this// match has no Node.js form.// Trivial example// l = [1, 2, 3, 4, 3, 2, 1]
as_arraylist values;as_arraylist_inita(&values, 2);as_arraylist_append_int64(&values, 2);as_arraylist_append_int64(&values, 3);
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_remove_by_value_list(&ops, "l", NULL, (as_list*)&values, AS_LIST_RETURN_COUNT);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "l" == 4// l == [1, 4, 1]
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4], ["v1", 5]]
as_arraylist pat1;as_arraylist_inita(&pat1, 2);as_arraylist_append_str(&pat1, "v1");as_arraylist_append(&pat1, (as_val*)&as_cmp_wildcard);
as_arraylist pat2;as_arraylist_inita(&pat2, 2);as_arraylist_append_str(&pat2, "v2");as_arraylist_append(&pat2, (as_val*)&as_cmp_wildcard);
as_arraylist patterns;as_arraylist_inita(&patterns, 2);as_arraylist_append(&patterns, (as_val*)&pat1);as_arraylist_append(&patterns, (as_val*)&pat2);
as_operations ops2;as_operations_inita(&ops2, 2);as_operations_list_remove_by_value_list(&ops2, "l", NULL, (as_list*)&patterns, AS_LIST_RETURN_NONE);as_operations_add_read(&ops2, "l");
as_record* rec2 = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops2, &rec2);// rec2 bins "l" == [["v3", 3]]// Trivial example// l = [1, 2, 3, 4, 3, 2, 1]
List<Value> removeValues = Arrays.asList(Value.get(2), Value.get(3));
Record record = client.operate(null, key, ListOperation.removeByValueList("l", removeValues, ListReturnType.COUNT));// returns 4// l == [1, 4, 1]
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4], ["v1", 5]]
List<Value> patterns = Arrays.asList( Value.get(Arrays.asList("v1", Value.WILDCARD)), Value.get(Arrays.asList("v2", Value.WILDCARD)));
record = client.operate(null, key, ListOperation.removeByValueList("l", patterns, ListReturnType.NONE), Operation.get("l"));// l == [["v3", 3]]# Trivial example# l = [1, 2, 3, 4, 3, 2, 1]
_, _, bins = client.operate(key, [ list_operations.list_remove_by_value_list("l", [2, 3], aerospike.LIST_RETURN_COUNT)])# bins["l"] == 4# l == [1, 4, 1]
# Matching tuples with wildcard# l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4], ["v1", 5]]
_, _, bins = client.operate(key, [ list_operations.list_remove_by_value_list( "l", [["v1", aerospike.CDTWildcard()], ["v2", aerospike.CDTWildcard()]], aerospike.LIST_RETURN_NONE ), operations.read("l"),])# bins["l"] == [["v3", 3]]remove_by_value(bin_name, value, result_type[, context])Removes all the elements in the list matching value. The INVERTED flag may be used to remove the elements not matching the specified value.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
value | any | Value to match. Every element equal to it is selected. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
Zero, one or a list of values, based on the return type. The NONE return type will execute faster because no reply is constructed for the operation. The elements returned by other return types may not be in index order.
Whether the list is unordered or ordered, remove_all_by_value will return the same elements, based on the ordering rules. The performance of ‘by value’ operations is better on an ordered list than an unordered one.
The worst-case performance of removing elements by value is 𝓞(log N + M) for an ordered list with a persisted index, 𝓞(log N + N) for an ordered list without a persisted index, and 𝓞(N + M) for an unordered list, where M is the number of items in the parameter list and N is the number of items already in the list.
Remove scalar values from the list. See the code sample below.
It is common to model complex data in Aerospike as a list of tuples, each element a list, where the index order carries meaning. For an example, see Aerospike Modeling: IoT Sensors.
In a list of mostly ordered pairs, we could remove a specific kind of element, such as all the tuples where the 0th position is “v2”, by using a wildcard (typically stylized as a * in documentation).
The wildcard matches any sequence of elements to the end of the tuple. In this example, this means matching any tuple whose first position is “v2”, and whose size is two or more elements.
The wildcard has different language-specific constructs, such as aerospike.CDTWildcard() in the Python client and Value.WILDCARD in the Java client.
// Trivial example// l = [1, 2, 1, 2]
try (RecordStream rs = session.upsert(key) .bin("l").onListValue(2).removeAnd().count() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 2}
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
try (RecordStream rs = session.upsert(key) .bin("l").onListValue(List.of("v2", SpecialValue.WILDCARD)) .removeAnd().getValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns [["v2", 2], ["v2", 4, {"a": 1}]]}# Trivial example# l = [1, 2, 1, 2]
stream = (session.upsert(key).bin("l").on_list_value(2) .remove(return_type=ListReturnType.COUNT).execute())# returns 2
# Matching tuples with wildcard# l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
stream = (session.upsert(key).bin("l").on_list_value(["v2", SpecialValue.WILDCARD]) .remove(return_type=ListReturnType.VALUE).execute())# returns [["v2", 2], ["v2", 4, {"a": 1}]]// Requires: use aerospike::operations::lists::{self, ListReturnType};// Trivial example// l = [1, 2, 1, 2]
let record = client.operate(&WritePolicy::default(), &key, &[lists::remove_by_value("l", as_val!(2), ListReturnType::Count)]).await?;// returns 2
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
let record = client.operate(&WritePolicy::default(), &key, &[lists::remove_by_value("l", as_list!("v2", Value::Wildcard), ListReturnType::Values)]).await?;// returns [["v2", 2], ["v2", 4, {"a": 1}]]// Trivial example// l = [1, 2, 1, 2]
Record record = client.Operate(null, key, ListOperation.RemoveByValue("l", Value.Get(2), ListReturnType.COUNT));// returns 2
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
record = client.Operate(null, key, ListOperation.RemoveByValue("l", Value.Get(new List<Value> { Value.Get("v2"), Value.WILDCARD }), ListReturnType.VALUE));// returns [["v2", 2], ["v2", 4, {"a": 1}]]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// Trivial example// l = [1, 2, 1, 2]
record, err := client.Operate(nil, key, as.ListRemoveByValueOp("l", 2, as.ListReturnTypeCount),)// record.Bins["l"] == 2
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
record, err = client.Operate(nil, key, as.ListRemoveByValueOp("l", []any{"v2", as.NewWildCardValue()}, as.ListReturnTypeValue),)// record.Bins["l"] == [["v2", 2], ["v2", 4, {"a": 1}]]// Trivial example// l = [1, 2, 1, 2]
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.removeByValue('l', 2).andReturn(lists.returnType.COUNT)])// result.bins.l == 2
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
// The Node.js client cannot put a wildcard inside a list value, so this// match has no Node.js form.// Trivial example// l = [1, 2, 1, 2]
as_integer val;as_integer_init(&val, 2);
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_remove_by_value(&ops, "l", NULL, (as_val*)&val, AS_LIST_RETURN_COUNT);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "l" == 2
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
as_arraylist match;as_arraylist_inita(&match, 2);as_arraylist_append_str(&match, "v2");as_arraylist_append(&match, (as_val*)&as_cmp_wildcard);
as_operations ops2;as_operations_inita(&ops2, 1);as_operations_list_remove_by_value(&ops2, "l", NULL, (as_val*)&match, AS_LIST_RETURN_VALUE);
as_record* rec2 = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops2, &rec2);// rec2 bins "l" == [["v2", 2], ["v2", 4, {"a": 1}]]// Trivial example// l = [1, 2, 1, 2]
Record record = client.operate(null, key, ListOperation.removeByValue("l", Value.get(2), ListReturnType.COUNT));// returns 2
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
record = client.operate(null, key, ListOperation.removeByValue("l", Value.get(Arrays.asList("v2", Value.WILDCARD)), ListReturnType.VALUE));// returns [["v2", 2], ["v2", 4, {"a": 1}]]# Trivial example# l = [1, 2, 1, 2]
_, _, bins = client.operate(key, [ list_operations.list_remove_by_value("l", 2, aerospike.LIST_RETURN_COUNT)])# bins["l"] == 2
# Matching tuples with wildcard# l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
_, _, bins = client.operate(key, [ list_operations.list_remove_by_value( "l", ["v2", aerospike.CDTWildcard()], aerospike.LIST_RETURN_VALUE )])# bins["l"] == [["v2", 2], ["v2", 4, {"a": 1}]]remove_by_index_range(bin_name, index[, count], result_type[, context])Removes a range of count elements starting at a specified list index. The INVERTED flag may be used to remove the elements not in a specified range.
The index and count can be any number, but the result may be an empty list if the specified range contains no elements.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
index | integer | Zero-based position, 0 being the first element. A negative index counts back from the end. |
count | integer | Number of elements to select. Optional; defaults to the rest of the collection. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
Zero, one or a list of values, based on the return type. The NONE return type will execute faster because no reply is constructed for the operation. The elements returned by other return types may not be in index order.
The worst-case performance of removing elements by index range is 𝓞(M) for an ordered list with a persisted index, and 𝓞(N + M) for an ordered list without a persisted index or an unordered list, where M is the element count of the range, and N is the element count of the list. Requesting a RANK return type on an unordered list adds 𝓞(L*N). See List performance.
For [1, 3, 3, 7, 0] with return type NONE a range starting at index 2 and containing 3 elements removes [3, 7, 0], while the INVERTED | NONE of the same range removes [1, 3].
// l = [1, 3, 3, 7, 0]
try (RecordStream rs = session.upsert(key) .bin("l").onListIndexRange(2, 3).remove() .execute()) { Record rec = rs.next().recordOrThrow();}// l == [1, 3]
// INVERTED: remove everything outside the range// l = [1, 3, 3, 7, 0]
try (RecordStream rs = session.upsert(key) .bin("l").onListIndexRange(2, 3).removeAllOthers() .execute()) { Record rec = rs.next().recordOrThrow();}// l == [3, 7, 0]# l = [1, 3, 3, 7, 0]
session.upsert(key).bin("l").on_list_index_range(2, 3).remove().execute()# l == [1, 3]
# INVERTED: remove everything outside the range# l = [1, 3, 3, 7, 0]
session.upsert(key).bin("l").on_list_index_range(2, 3).remove_all_others().execute()# l == [3, 7, 0]// Requires: use aerospike::operations::lists::{self, InvertedListReturn, ListReturnType};// l = [1, 3, 3, 7, 0]
client.operate(&WritePolicy::default(), &key, &[lists::remove_by_index_range_count("l", 2, 3, ListReturnType::None)]).await?;// l == [1, 3]
// INVERTED: remove everything outside the range// l = [1, 3, 3, 7, 0]
client.operate(&WritePolicy::default(), &key, &[lists::remove_by_index_range_count("l", 2, 3, InvertedListReturn(ListReturnType::None))]).await?;// l == [3, 7, 0]// l = [1, 3, 3, 7, 0]
client.Operate(null, key, ListOperation.RemoveByIndexRange("l", 2, 3, ListReturnType.NONE));// l == [1, 3]
// INVERTED: remove everything outside the range// l = [1, 3, 3, 7, 0]
client.Operate(null, key, ListOperation.RemoveByIndexRange("l", 2, 3, ListReturnType.NONE | ListReturnType.INVERTED));// l == [3, 7, 0]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// l = [1, 3, 3, 7, 0]
_, err := client.Operate(nil, key, as.ListRemoveByIndexRangeCountOp("l", 2, 3, as.ListReturnTypeNone),)// l == [1, 3]
// INVERTED: remove everything outside the range// l = [1, 3, 3, 7, 0]
_, err = client.Operate(nil, key, as.ListRemoveByIndexRangeCountOp("l", 2, 3, as.ListReturnTypeNone|as.ListReturnTypeInverted),)// l == [3, 7, 0]// l = [1, 3, 3, 7, 0]
const lists = Aerospike.lists
await client.operate(key, [ lists.removeByIndexRange('l', 2, 3).andReturn(lists.returnType.NONE)])// l == [1, 3]
// INVERTED: remove everything outside the range// l = [1, 3, 3, 7, 0]
await client.operate(key, [ lists.removeByIndexRange('l', 2, 3) .invertSelection() .andReturn(lists.returnType.NONE)])// l == [3, 7, 0]// l = [1, 3, 3, 7, 0]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_remove_by_index_range(&ops, "l", NULL, 2, 3, AS_LIST_RETURN_NONE);
aerospike_key_operate(&as, &err, NULL, &key, &ops, NULL);// l == [1, 3]
// INVERTED: remove everything outside the range// l = [1, 3, 3, 7, 0]
as_operations ops2;as_operations_inita(&ops2, 1);as_operations_list_remove_by_index_range(&ops2, "l", NULL, 2, 3, AS_LIST_RETURN_NONE | AS_LIST_RETURN_INVERTED);
aerospike_key_operate(&as, &err, NULL, &key, &ops2, NULL);// l == [3, 7, 0]// l = [1, 3, 3, 7, 0]
client.operate(null, key, ListOperation.removeByIndexRange("l", 2, 3, ListReturnType.NONE));// l == [1, 3]
// INVERTED: remove everything outside the range// l = [1, 3, 3, 7, 0]
client.operate(null, key, ListOperation.removeByIndexRange("l", 2, 3, ListReturnType.NONE | ListReturnType.INVERTED));// l == [3, 7, 0]# l = [1, 3, 3, 7, 0]
client.operate(key, [ list_operations.list_remove_by_index_range("l", 2, aerospike.LIST_RETURN_NONE, 3)])# l == [1, 3]
# INVERTED: remove everything outside the range# l = [1, 3, 3, 7, 0]
client.operate(key, [ list_operations.list_remove_by_index_range( "l", 2, aerospike.LIST_RETURN_NONE, 3, inverted=True)])# l == [3, 7, 0]remove_by_index(bin_name, index, result_type[, context])Removes the element at the specified list index. The index must be a number between 0 and N-1, where N is the length of the list. The index can also be a negative number, with -1 being the last element by index position.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
index | integer | Zero-based position, 0 being the first element. A negative index counts back from the end. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
Zero or one value, based on the return type. The NONE return type will execute faster because no reply is constructed for the operation.
An Operation Not Applicable error (code 26) when trying to remove an inaccessible index.
The worst-case performance of removing the element by index is 𝓞(1) for an ordered list with a persisted index, and 𝓞(N) for an ordered list without a persisted index or an unordered list.
// scores = [10, 20, 30, 40, 50]
try (RecordStream rs = session.upsert(key) .bin("scores").onListIndex(2).removeAnd().getValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 30}// scores == [10, 20, 40, 50]# scores = [10, 20, 30, 40, 50]
stream = (session.upsert(key).bin("scores").on_list_index(2) .remove(return_type=ListReturnType.VALUE).execute())# returns 30# scores == [10, 20, 40, 50]// Requires: use aerospike::operations::lists::{self, ListReturnType};// scores = [10, 20, 30, 40, 50]
let record = client.operate(&WritePolicy::default(), &key, &[lists::remove_by_index("scores", 2, ListReturnType::Values)]).await?;// returns 30// scores == [10, 20, 40, 50]// scores = [10, 20, 30, 40, 50]
Record record = client.Operate(null, key, ListOperation.RemoveByIndex("scores", 2, ListReturnType.VALUE));// returns 30// scores == [10, 20, 40, 50]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// scores = [10, 20, 30, 40, 50]
record, err := client.Operate(nil, key, as.ListRemoveByIndexOp("scores", 2, as.ListReturnTypeValue),)// record.Bins["scores"] == 30// scores == [10, 20, 40, 50]// scores = [10, 20, 30, 40, 50]
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.removeByIndex('scores', 2).andReturn(lists.returnType.VALUE)])// result.bins.scores == 30// scores == [10, 20, 40, 50]// scores = [10, 20, 30, 40, 50]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_remove_by_index(&ops, "scores", NULL, 2, AS_LIST_RETURN_VALUE);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "scores" == 30// scores == [10, 20, 40, 50]// scores = [10, 20, 30, 40, 50]
Record record = client.operate(null, key, ListOperation.removeByIndex("scores", 2, ListReturnType.VALUE));// returns 30// scores == [10, 20, 40, 50]# scores = [10, 20, 30, 40, 50]
_, _, bins = client.operate(key, [ list_operations.list_remove_by_index("scores", 2, aerospike.LIST_RETURN_VALUE)])# bins["scores"] == 30# scores == [10, 20, 40, 50]remove_by_rank_range(bin_name, rank[, count], result_type[, context])Removes a range of count elements starting at a specified rank. The INVERTED flag may be used to remove the elements not in a specified range.
The rank and count can be any number, but the result may be an empty list if the specified range contains no elements.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
rank | integer | Zero-based rank in value order, 0 being the smallest. A negative rank counts back from the largest. |
count | integer | Number of elements to select. Optional; defaults to the rest of the collection. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
Zero, one or a list of values, based on the return type. The NONE return type will execute faster because no reply is constructed for the operation. The elements returned by other return types may not be in rank order.
The worst-case performance of removing elements by rank range is 𝓞(M) for an ordered list with a persisted index. An ordered list without a persisted index has a 𝓞(N + M), where M is the element count of the range, and N is the element count of the list. An unordered list has a 𝓞(R log N + N).
For [1, 3, 2, 7, 0] with return type NONE a range starting at rank 2 and containing 2 elements removes [2, 3], while the INVERTED | NONE of the same range removes [0, 1, 7].
// l = [1, 3, 2, 7, 0]
try (RecordStream rs = session.upsert(key) .bin("l").onListRankRange(2, 2).remove() .execute()) { Record rec = rs.next().recordOrThrow();}// l == [1, 7, 0]
// INVERTED: remove everything outside the range// l = [1, 3, 2, 7, 0]
try (RecordStream rs = session.upsert(key) .bin("l").onListRankRange(2, 2).removeAllOthers() .execute()) { Record rec = rs.next().recordOrThrow();}// l == [3, 2]# l = [1, 3, 2, 7, 0]
session.upsert(key).bin("l").on_list_rank_range(2, 2).remove().execute()# l == [1, 7, 0]
# INVERTED: remove everything outside the range# l = [1, 3, 2, 7, 0]
session.upsert(key).bin("l").on_list_rank_range(2, 2).remove_all_others().execute()# l == [3, 2]// Requires: use aerospike::operations::lists::{self, InvertedListReturn, ListReturnType};// l = [1, 3, 2, 7, 0]
client.operate(&WritePolicy::default(), &key, &[lists::remove_by_rank_range_count("l", 2, 2, ListReturnType::None)]).await?;// l == [1, 7, 0]
// INVERTED: remove everything outside the range// l = [1, 3, 2, 7, 0]
client.operate(&WritePolicy::default(), &key, &[lists::remove_by_rank_range_count("l", 2, 2, InvertedListReturn(ListReturnType::None))]).await?;// l == [3, 2]// l = [1, 3, 2, 7, 0]
client.Operate(null, key, ListOperation.RemoveByRankRange("l", 2, 2, ListReturnType.NONE));// l == [1, 7, 0]
// INVERTED: remove everything outside the range// l = [1, 3, 2, 7, 0]
client.Operate(null, key, ListOperation.RemoveByRankRange("l", 2, 2, ListReturnType.NONE | ListReturnType.INVERTED));// l == [3, 2]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// l = [1, 3, 2, 7, 0]
_, err := client.Operate(nil, key, as.ListRemoveByRankRangeCountOp("l", 2, 2, as.ListReturnTypeNone),)// l == [1, 7, 0]
// INVERTED: remove everything outside the range// l = [1, 3, 2, 7, 0]
_, err = client.Operate(nil, key, as.ListRemoveByRankRangeCountOp("l", 2, 2, as.ListReturnTypeNone|as.ListReturnTypeInverted),)// l == [3, 2]// l = [1, 3, 2, 7, 0]
const lists = Aerospike.lists
await client.operate(key, [ lists.removeByRankRange('l', 2, 2).andReturn(lists.returnType.NONE)])// l == [1, 7, 0]
// INVERTED: remove everything outside the range// l = [1, 3, 2, 7, 0]
await client.operate(key, [ lists.removeByRankRange('l', 2, 2) .invertSelection() .andReturn(lists.returnType.NONE)])// l == [3, 2]// l = [1, 3, 2, 7, 0]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_remove_by_rank_range(&ops, "l", NULL, 2, 2, AS_LIST_RETURN_NONE);
aerospike_key_operate(&as, &err, NULL, &key, &ops, NULL);// l == [1, 7, 0]
// INVERTED: remove everything outside the range// l = [1, 3, 2, 7, 0]
as_operations ops2;as_operations_inita(&ops2, 1);as_operations_list_remove_by_rank_range(&ops2, "l", NULL, 2, 2, AS_LIST_RETURN_NONE | AS_LIST_RETURN_INVERTED);
aerospike_key_operate(&as, &err, NULL, &key, &ops2, NULL);// l == [3, 2]// l = [1, 3, 2, 7, 0]
client.operate(null, key, ListOperation.removeByRankRange("l", 2, 2, ListReturnType.NONE));// l == [1, 7, 0]
// INVERTED: remove everything outside the range// l = [1, 3, 2, 7, 0]
client.operate(null, key, ListOperation.removeByRankRange("l", 2, 2, ListReturnType.NONE | ListReturnType.INVERTED));// l == [3, 2]# l = [1, 3, 2, 7, 0]
client.operate(key, [ list_operations.list_remove_by_rank_range("l", 2, aerospike.LIST_RETURN_NONE, 2)])# l == [1, 7, 0]
# INVERTED: remove everything outside the range# l = [1, 3, 2, 7, 0]
client.operate(key, [ list_operations.list_remove_by_rank_range( "l", 2, aerospike.LIST_RETURN_NONE, 2, inverted=True)])# l == [3, 2]remove_by_value_range(bin_name, value_begin, value_end, result_type[, context])Removes the list elements that sort into the interval between valueStart (inclusive) and valueStop (exclusive). The INVERTED flag may be used to remove the elements outside this interval.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
value_begin | any | Lowest value to match, inclusive. |
value_end | any | Upper bound on the value, exclusive. Omit it to match everything from |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
Zero, one or a list of values, based on the return type. The elements returned may not be in index order.
Whether the list is unordered or ordered, remove_by_value_interval will return the same elements, based on the ordering rules. The performance of ‘by value’ operations is better on an ordered list than an unordered one.
The worst-case performance of removing elements in a value interval is 𝓞(log N + M) for an ordered list with a persisted index, 𝓞(log N + N) for an ordered list without a persisted index, and 𝓞(N + M) for an unordered list, where M is the number of items in the parameter list and N is the number of items already in the list.
Remove the list elements in the interval between two scalar values. See the code sample below.
It is common to model complex data in Aerospike as a list of tuples, each element a list, where the index order carries meaning. For an example, see Aerospike Modeling: IoT Sensors.
This modeling relies on the ordering rules that apply to list elements. Ordered pairs sort into
[1, NIL] < [1, 1] < [1, 1, 2] < [1, 2] < [1, '1'] < [1, 1.0] < [1, INF]
Take the list of ordered pairs, [[100, 1], [101, 2], [102, 3], [103, 4], [104, 5]] and the following intervals:
valueStart: [101, NIL], valueStop: [103, NIL]
Iterating over the elements we check if [101, NIL] <= value < [103, NIL]. This is true for the elements [101, 2] and [102, 3]. The element [103, 4] is not in this interval, because its order is higher than [103, NIL]. The comparison starts with the 0th index values, in this case both are 103. Next the 1st index position values are compared, and NIL is lower than 3 (actually its order is lower than any value).
valueStart: [101, NIL], valueStop: [103, INF]
The elements [101, 2] and [102, 3] are obviously in the interval. The element [103, 4] is also in this interval, because its order is lower than [103, INF]. The comparison starts with the 0th index values, in this case both are 103. Next the 1st index position values are compared, and INF is higher than 3 (actually its order is higher than any value).
valueStart: [101, INF], valueStop: [103, INF]
The elements [102, 3] and [103, 4] are in the interval. The element [101, 2] is not in this interval, because its order is lower than [101, INF].
// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// remove all elements in the interval [2, 4), then read the bintry (RecordStream rs = session.upsert(key) .bin("l").onListValueRange(2, 4).remove() .bin("l").get() .execute()) { Record rec = rs.next().recordOrThrow();}// l == [1, 4, 5, 4, 1]# l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
# remove all elements in the interval [2, 4), then read the binstream = (session.upsert(key).bin("l").on_list_value_range(2, 4).remove() .bin("l").get().execute())# l == [1, 4, 5, 4, 1]// Requires: use aerospike::operations::{self, lists::{self, ListReturnType}};// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// remove all elements in the interval [2, 4), then read the binlet record = client.operate(&WritePolicy::default(), &key, &[lists::remove_by_value_range("l", ListReturnType::None, as_val!(2), as_val!(4)), operations::get_bin("l")]).await?;// l == [1, 4, 5, 4, 1]// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// remove all elements in the interval [2, 4), then read the binRecord record = client.Operate(null, key, ListOperation.RemoveByValueRange("l", Value.Get(2), Value.Get(4), ListReturnType.NONE), Operation.Get("l"));// l == [1, 4, 5, 4, 1]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// remove all elements in the interval [2, 4), then read the binrecord, err := client.Operate(nil, key, as.ListRemoveByValueRangeOp("l", as.ListReturnTypeNone, 2, 4), as.GetBinOp("l"),)// record.Bins["l"] == [1, 4, 5, 4, 1]// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// remove all elements in the interval [2, 4), then read the binconst lists = Aerospike.lists
const result = await client.operate(key, [ lists.removeByValueRange('l', 2, 4).andReturn(lists.returnType.NONE), Aerospike.operations.read('l')])// result.bins.l == [1, 4, 5, 4, 1]// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// remove all elements in the interval [2, 4), then read the binas_integer begin;as_integer_init(&begin, 2);as_integer end;as_integer_init(&end, 4);
as_operations ops;as_operations_inita(&ops, 2);as_operations_list_remove_by_value_range(&ops, "l", NULL, (as_val*)&begin, (as_val*)&end, AS_LIST_RETURN_NONE);as_operations_add_read(&ops, "l");
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "l" == [1, 4, 5, 4, 1]// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// remove all elements in the interval [2, 4), then read the binRecord record = client.operate(null, key, ListOperation.removeByValueRange("l", Value.get(2), Value.get(4), ListReturnType.NONE), Operation.get("l"));// l == [1, 4, 5, 4, 1]# l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
# remove all elements in the interval [2, 4), then read the bin_, _, bins = client.operate(key, [ list_operations.list_remove_by_value_range( "l", aerospike.LIST_RETURN_NONE, 2, 4), operations.read("l"),])# bins["l"] == [1, 4, 5, 4, 1]remove_by_value_rel_rank_range(bin_name, value, rank[, count], result_type[, context])Removes a range of count elements starting at a specified rank, relative to the given value. The INVERTED flag may be used to remove the elements not in a specified range.
The value can be anything, not necessarily a value that exists in the list. The rank and count can be any number, but the result may be an empty list if the specified range contains no elements.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
value | any | Value that |
rank | integer | Zero-based rank in value order, 0 being the smallest. A negative rank counts back from the largest. |
count | integer | Number of elements to select. Optional; defaults to the rest of the collection. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
Zero, one or a list of values, based on the return type. The elements returned may not be in rank order.
The relative rank of the value compared to the current list follows the ordering rules.
The worst-case performance of removing elements by relative rank range is 𝓞(M + log N) for an ordered list with a persisted index. An ordered list without a persisted index has a 𝓞(N + M + log N), where M is the element count of the range, and N is the element count of the list. An unordered list has a 𝓞(R log N + N), with R for rank.
For [0, 3, 9, 12, 15] a value of 5 would rank between 3 and 9, relative to the current list. A rank of -1 from there would select 3 as the starting point of the range, and then the count would select the elements. So a count of 3 would remove the elements 3, 9 and 12.
// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → remove ranks 1..3
try (RecordStream rs = session.upsert(key) .bin("scores").onListValueRelativeRankRange(5, -1, 3) .removeAnd().getValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 3, 9 and 12, in no guaranteed order}// scores == [0, 15]# scores = [0, 3, 9, 12, 15]# Relative rank of value 5: between 3 and 9 (rank position 2)# rank offset -1, count 3 → remove ranks 1..3
stream = (session.upsert(key).bin("scores") .on_list_value_relative_rank_range(5, -1, 3) .remove(return_type=ListReturnType.VALUE).execute())# returns 3, 9 and 12, in no guaranteed order# scores == [0, 15]// Requires: use aerospike::operations::lists::{self, ListReturnType};// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → remove ranks 1..3
let record = client.operate(&WritePolicy::default(), &key, &[lists::remove_by_value_relative_rank_range_count("scores", ListReturnType::Values, as_val!(5), -1, 3)]).await?;// returns 3, 9 and 12, in no guaranteed order// scores == [0, 15]// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → remove ranks 1..3
Record record = client.Operate(null, key, ListOperation.RemoveByValueRelativeRankRange("scores", Value.Get(5), -1, 3, ListReturnType.VALUE));// returns 3, 9 and 12, in no guaranteed order// scores == [0, 15]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → remove ranks 1..3
record, err := client.Operate(nil, key, as.ListRemoveByValueRelativeRankRangeCountOp("scores", as.ListReturnTypeValue, 5, -1, 3),)// record.Bins["scores"] holds 3, 9 and 12, in no guaranteed order// scores == [0, 15]// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → remove ranks 1..3
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.removeByValueRelRankRange('scores', 5, -1, 3) .andReturn(lists.returnType.VALUE)])// result.bins.scores holds 3, 9 and 12, in no guaranteed order// scores == [0, 15]// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → remove ranks 1..3
as_integer val;as_integer_init(&val, 5);
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_remove_by_value_rel_rank_range(&ops, "scores", NULL, (as_val*)&val, -1, 3, AS_LIST_RETURN_VALUE);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "scores" holds 3, 9 and 12, in no guaranteed order// scores == [0, 15]// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → remove ranks 1..3
Record record = client.operate(null, key, ListOperation.removeByValueRelativeRankRange("scores", Value.get(5), -1, 3, ListReturnType.VALUE));// returns 3, 9 and 12, in no guaranteed order// scores == [0, 15]# scores = [0, 3, 9, 12, 15]# Relative rank of value 5: between 3 and 9 (rank position 2)# rank offset -1, count 3 → remove ranks 1..3
_, _, bins = client.operate(key, [ list_operations.list_remove_by_value_rank_range_relative( "scores", 5, -1, aerospike.LIST_RETURN_VALUE, 3)])# bins["scores"] holds 3, 9 and 12, in no guaranteed order# scores == [0, 15]set(policy, bin_name, index, value[, context])Creates an unordered list bin, if the bin does not exist. Sets or overwrites a value at the specified list index. (This set function has no relation to the Aerospike concept of sets as a collection of records.)
By default the index can be any number, and NIL values will be added as padding to the left of the new element, as needed. Using the INSERT_BOUNDED policy, a developer can limit this behavior, and only allow for an element to be set at an index value between 0 and the size of the list.
You cannot set a value in an ordered list, only append or append_items to one.
| Name | Type | Description |
|---|---|---|
policy | List policy | Ordering and write flags for the operation. See Write flags. The ordering attribute takes effect only when this operation creates the list; on a list that already exists it is ignored. |
bin_name | string | Name of the bin to operate on. |
index | integer | Zero-based position, 0 being the first element. A negative index counts back from the end. |
value | any | Element to write at |
context | Context 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 list. |
The element count due to the operation, in the ‘bins’ part of the record under the bin name.
A list newly created with set() is always unordered.
The worst-case performance of setting an item at the head of a list (at its 0th index) is 𝓞(1). At any other index it is 𝓞(N).
// scores = [10, 20, 30]
try (RecordStream rs = session.upsert(key) .bin("scores").listSet(1, 25) .execute()) { Record rec = rs.next().recordOrThrow();}// scores == [10, 25, 30]# scores = [10, 20, 30]
session.upsert(key).bin("scores").list_set(1, 25).execute()# scores == [10, 25, 30]// Requires: use aerospike::operations::lists::{self};// scores = [10, 20, 30]
client.operate(&WritePolicy::default(), &key, &[lists::set("scores", 1, as_val!(25))]).await?;// scores == [10, 25, 30]// scores = [10, 20, 30]
client.Operate(null, key, ListOperation.Set("scores", 1, Value.Get(25)));// scores == [10, 25, 30]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// scores = [10, 20, 30]
_, err := client.Operate(nil, key, as.ListSetOp("scores", 1, 25),)// scores == [10, 25, 30]// scores = [10, 20, 30]
const lists = Aerospike.lists
await client.operate(key, [ lists.set('scores', 1, 25)])// scores == [10, 25, 30]// scores = [10, 20, 30]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_set(&ops, "scores", NULL, NULL, 1, (as_val*)as_integer_new(25));
aerospike_key_operate(&as, &err, NULL, &key, &ops, NULL);// scores == [10, 25, 30]// scores = [10, 20, 30]
Record record = client.operate(null, key, ListOperation.set("scores", 1, Value.get(25)));// scores == [10, 25, 30]# scores = [10, 20, 30]
_, _, bins = client.operate(key, [ list_operations.list_set("scores", 1, 25)])# scores == [10, 25, 30]sort(bin_name, sort_flags[, context])Sorts a list, but doesn’t change the list order. An unordered list will remain unordered after being sorted. An ordered list doesn’t need to be sorted, because by definition it sorts itself any time elements are added to it.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
sort_flags | integer literal | Sort flags: |
context | Context 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 list. |
null
| Flag | Description |
|---|---|
DEFAULT | Default keep duplicates |
DROP_DUPLICATES | Drop duplicates while sorting |
The sort operation will do no work when called on an already ordered list. The worst-case performance of sorting an unordered list is 𝓞(N log N).
// scores = [30, 10, 50, 20, 40]
try (RecordStream rs = session.upsert(key) .bin("scores").listSort() .execute()) { Record rec = rs.next().recordOrThrow();}// scores == [10, 20, 30, 40, 50]# scores = [30, 10, 50, 20, 40]
session.upsert(key).bin("scores").list_sort().execute()# scores == [10, 20, 30, 40, 50]// Requires: use aerospike::operations::lists::{self, ListSortFlags};// scores = [30, 10, 50, 20, 40]
client.operate(&WritePolicy::default(), &key, &[lists::sort("scores", ListSortFlags::Default)]).await?;// scores == [10, 20, 30, 40, 50]// scores = [30, 10, 50, 20, 40]
client.Operate(null, key, ListOperation.Sort("scores", ListSortFlags.DEFAULT));// scores == [10, 20, 30, 40, 50]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// scores = [30, 10, 50, 20, 40]
_, err := client.Operate(nil, key, as.ListSortOp("scores", as.ListSortFlagsDefault),)// scores == [10, 20, 30, 40, 50]// scores = [30, 10, 50, 20, 40]
const lists = Aerospike.lists
await client.operate(key, [ lists.sort('scores', lists.sortFlags.DEFAULT)])// scores == [10, 20, 30, 40, 50]// scores = [30, 10, 50, 20, 40]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_sort(&ops, "scores", NULL, AS_LIST_SORT_DEFAULT);
aerospike_key_operate(&as, &err, NULL, &key, &ops, NULL);// scores == [10, 20, 30, 40, 50]// scores = [30, 10, 50, 20, 40]
client.operate(null, key, ListOperation.sort("scores", ListSortFlags.DEFAULT));// scores == [10, 20, 30, 40, 50]# scores = [30, 10, 50, 20, 40]
client.operate(key, [ list_operations.list_sort("scores")])# scores == [10, 20, 30, 40, 50]Read operations
get_by_value_list(bin_name, values, result_type[, context])Gets all the elements in the list matching one of the specified values. The INVERTED flag may be used to get the elements not matching any of the values.
Whether the list is unordered or ordered, get_all_by_value_list will return the same elements, based on the ordering rules. The performance of ‘by value’ operations is better on an ordered list than an unordered one.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
values | list | Values to match, as a list. Every element equal to any of them is selected. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
Zero, one or a list of values, based on the return type. The elements returned may not be in index order.
The worst-case performance of getting elements by a value list is 𝓞((M+N) log M) for an ordered list with a persisted index, 𝓞((M+N) log M + N) for an ordered list without a persisted index, or for an unordered list, where M is the number of items in the parameter list and N is the number of items already in the list.
Count the number of elements in the list matching one of several specified scalar values. See the code sample below.
See the example given for get_all_by_value.
In a list of mostly ordered pairs, we could search for all the tuples that do not start with “v1” or “v2”, by using a wildcard and an INVERTED | VALUE return type.
The wildcard matches any sequence of elements to the end of the tuple. In this example, this means matching any tuple whose first position is “v1” or “v2”, and whose size is two or more elements.
The wildcard has different language-specific constructs, such as aerospike.CDTWildcard() in the Python client and Value.WILDCARD in the Java client.
// Trivial example// l = [1, 2, 3, 2, 1]
try (RecordStream rs = session.query(key) .bin("l").onListValueList(List.of(2, 3)).count() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 3}
// Matching tuples with wildcard (INVERTED)// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4]]
try (RecordStream rs = session.query(key) .bin("l").onListValueList(List.of( List.of("v2", SpecialValue.WILDCARD), List.of("v1", SpecialValue.WILDCARD))).getAllOtherValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns [["v3", 3]]}# Trivial example# l = [1, 2, 3, 2, 1]
stream = session.query(key).bin("l").on_list_value_list([2, 3]).count().execute()# returns 3
# Matching tuples with wildcard (INVERTED)# l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4]]
stream = (session.query(key).bin("l") .on_list_value_list([["v2", SpecialValue.WILDCARD], ["v1", SpecialValue.WILDCARD]]) .get_all_other_values().execute())# returns [["v3", 3]]// Requires: use aerospike::operations::lists::{self, InvertedListReturn, ListReturnType};// Trivial example// l = [1, 2, 3, 2, 1]
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_value_list("l", as_values!(2, 3), ListReturnType::Count)]).await?;// returns 3
// Matching tuples with wildcard (INVERTED)// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4]]
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_value_list("l", vec![as_list!("v2", Value::Wildcard), as_list!("v1", Value::Wildcard)], InvertedListReturn(ListReturnType::Values))]).await?;// returns [["v3", 3]]// Trivial example// l = [1, 2, 3, 2, 1]
IList filterValues = new List<Value> { Value.Get(2), Value.Get(3)};
Record record = client.Operate(null, key, ListOperation.GetByValueList("l", filterValues, ListReturnType.COUNT));// returns 3
// Matching tuples with wildcard (INVERTED)// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4]]
IList patterns = new List<Value> { Value.Get(new List<Value> { Value.Get("v2"), Value.WILDCARD }), Value.Get(new List<Value> { Value.Get("v1"), Value.WILDCARD })};
record = client.Operate(null, key, ListOperation.GetByValueList("l", patterns, ListReturnType.VALUE | ListReturnType.INVERTED));// returns [["v3", 3]]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// Trivial example// l = [1, 2, 3, 2, 1]
record, err := client.Operate(nil, key, as.ListGetByValueListOp("l", []any{2, 3}, as.ListReturnTypeCount),)// record.Bins["l"] == 3
// Matching tuples with wildcard (INVERTED)// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4]]
record, err = client.Operate(nil, key, as.ListGetByValueListOp("l", []any{ []any{"v2", as.NewWildCardValue()}, []any{"v1", as.NewWildCardValue()}, }, as.ListReturnTypeValue|as.ListReturnTypeInverted),)// record.Bins["l"] == [["v3", 3]]// Trivial example// l = [1, 2, 3, 2, 1]
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.getByValueList('l', [2, 3]).andReturn(lists.returnType.COUNT)])// result.bins.l == 3
// Matching tuples with wildcard (INVERTED)// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4]]
// The Node.js client cannot put a wildcard inside a list value, so this// match has no Node.js form.// Trivial example// l = [1, 2, 3, 2, 1]
as_arraylist values;as_arraylist_inita(&values, 2);as_arraylist_append_int64(&values, 2);as_arraylist_append_int64(&values, 3);
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_get_by_value_list(&ops, "l", NULL, (as_list*)&values, AS_LIST_RETURN_COUNT);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "l" == 3
// Matching tuples with wildcard (INVERTED)// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4]]
as_arraylist pat1;as_arraylist_inita(&pat1, 2);as_arraylist_append_str(&pat1, "v2");as_arraylist_append(&pat1, (as_val*)&as_cmp_wildcard);
as_arraylist pat2;as_arraylist_inita(&pat2, 2);as_arraylist_append_str(&pat2, "v1");as_arraylist_append(&pat2, (as_val*)&as_cmp_wildcard);
as_arraylist patterns;as_arraylist_inita(&patterns, 2);as_arraylist_append(&patterns, (as_val*)&pat1);as_arraylist_append(&patterns, (as_val*)&pat2);
as_operations ops2;as_operations_inita(&ops2, 1);as_operations_list_get_by_value_list(&ops2, "l", NULL, (as_list*)&patterns, AS_LIST_RETURN_VALUE | AS_LIST_RETURN_INVERTED);
as_record* rec2 = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops2, &rec2);// rec2 bins "l" == [["v3", 3]]// Trivial example// l = [1, 2, 3, 2, 1]
List<Value> filterValues = Arrays.asList(Value.get(2), Value.get(3));
Record record = client.operate(null, key, ListOperation.getByValueList("l", filterValues, ListReturnType.COUNT));// returns 3
// Matching tuples with wildcard (INVERTED)// l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4]]
List<Value> patterns = Arrays.asList( Value.get(Arrays.asList("v2", Value.WILDCARD)), Value.get(Arrays.asList("v1", Value.WILDCARD)));
record = client.operate(null, key, ListOperation.getByValueList("l", patterns, ListReturnType.VALUE | ListReturnType.INVERTED));// returns [["v3", 3]]# Trivial example# l = [1, 2, 3, 2, 1]
_, _, bins = client.operate(key, [ list_operations.list_get_by_value_list("l", [2, 3], aerospike.LIST_RETURN_COUNT)])# bins["l"] == 3
# Matching tuples with wildcard (INVERTED)# l = [["v1", 1], ["v2", 2], ["v3", 3], ["v2", 4]]
wildcard = aerospike.CDTWildcard()_, _, bins = client.operate(key, [ list_operations.list_get_by_value_list( "l", [["v2", wildcard], ["v1", wildcard]], aerospike.LIST_RETURN_VALUE, inverted=True, )])# bins["l"] == [["v3", 3]]get_by_value(bin_name, value, result_type[, context])Gets all the elements in the list matching value. The INVERTED flag may be used to get the elements not matching the specified value.
Whether the list is unordered or ordered, get_all_by_value will return the same elements, based on the ordering rules. The performance of ‘by value’ operations is better on an ordered list than an unordered one.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
value | any | Value to match. Every element equal to it is selected. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
Zero, one or a list of values, based on the return type. The elements returned may not be in index order.
The worst-case performance of getting elements by value is 𝓞(log N + M) for an ordered list with a persisted index, 𝓞(log N + N) for an ordered list without a persisted index, and 𝓞(N + M) for an unordered list, where M is the number of items in the parameter list and N is the number of items already in the list.
Count the number of elements in the list with a specified scalar value. See the code sample below.
It is common to model complex data in Aerospike as a list of tuples, each element a list, where the index order carries meaning. For an example, see Aerospike Modeling: IoT Sensors.
In a list of mostly ordered pairs, we could search for a specific kind of element, such as all the tuples where the 0th position is “v2”, by using a wildcard (typically stylized as a * in documentation).
The wildcard matches any sequence of elements to the end of the tuple. In this example, this means matching any tuple whose first position is “v2”, and whose size is two or more elements.
The wildcard has different language-specific constructs, such as aerospike.CDTWildcard() in the Python client and Value.WILDCARD in the Java client.
// Trivial example// l = [1, 2, 1, 2]
try (RecordStream rs = session.query(key) .bin("l").onListValue(2).count() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 2}
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
try (RecordStream rs = session.query(key) .bin("l").onListValue(List.of("v2", SpecialValue.WILDCARD)).getValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns [["v2", 2], ["v2", 4, {"a": 1}]]}# Trivial example# l = [1, 2, 1, 2]
stream = session.query(key).bin("l").on_list_value(2).count().execute()# returns 2
# Matching tuples with wildcard# l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
stream = (session.query(key).bin("l") .on_list_value(["v2", SpecialValue.WILDCARD]).get_values().execute())# returns [["v2", 2], ["v2", 4, {"a": 1}]]// Requires: use aerospike::operations::lists::{self, ListReturnType};// Trivial example// l = [1, 2, 1, 2]
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_value("l", as_val!(2), ListReturnType::Count)]).await?;// returns 2
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_value("l", as_list!("v2", Value::Wildcard), ListReturnType::Values)]).await?;// returns [["v2", 2], ["v2", 4, {"a": 1}]]// Trivial example// l = [1, 2, 1, 2]
Record record = client.Operate(null, key, ListOperation.GetByValue("l", Value.Get(2), ListReturnType.COUNT));// returns 2
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
record = client.Operate(null, key, ListOperation.GetByValue("l", Value.Get(new List<Value> { Value.Get("v2"), Value.WILDCARD }), ListReturnType.VALUE));// returns [["v2", 2], ["v2", 4, {"a": 1}]]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// Trivial example// l = [1, 2, 1, 2]
record, err := client.Operate(nil, key, as.ListGetByValueOp("l", 2, as.ListReturnTypeCount),)// record.Bins["l"] == 2
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
record, err = client.Operate(nil, key, as.ListGetByValueOp("l", []any{"v2", as.NewWildCardValue()}, as.ListReturnTypeValue),)// record.Bins["l"] == [["v2", 2], ["v2", 4, {"a": 1}]]// Trivial example// l = [1, 2, 1, 2]
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.getByValue('l', 2).andReturn(lists.returnType.COUNT)])// result.bins.l == 2
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
// The Node.js client cannot put a wildcard inside a list value, so this// match has no Node.js form.// Trivial example// l = [1, 2, 1, 2]
as_integer val;as_integer_init(&val, 2);
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_get_by_value(&ops, "l", NULL, (as_val*)&val, AS_LIST_RETURN_COUNT);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "l" == 2
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
as_arraylist match;as_arraylist_inita(&match, 2);as_arraylist_append_str(&match, "v2");as_arraylist_append(&match, (as_val*)&as_cmp_wildcard);
as_operations ops2;as_operations_inita(&ops2, 1);as_operations_list_get_by_value(&ops2, "l", NULL, (as_val*)&match, AS_LIST_RETURN_VALUE);
as_record* rec2 = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops2, &rec2);// rec2 bins "l" == [["v2", 2], ["v2", 4, {"a": 1}]]// Trivial example// l = [1, 2, 1, 2]
Record record = client.operate(null, key, ListOperation.getByValue("l", Value.get(2), ListReturnType.COUNT));// returns 2
// Matching tuples with wildcard// l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
record = client.operate(null, key, ListOperation.getByValue("l", Value.get(Arrays.asList("v2", Value.WILDCARD)), ListReturnType.VALUE));// returns [["v2", 2], ["v2", 4, {"a": 1}]]# Trivial example# l = [1, 2, 1, 2]
_, _, bins = client.operate(key, [ list_operations.list_get_by_value("l", 2, aerospike.LIST_RETURN_COUNT)])# bins["l"] == 2
# Matching tuples with wildcard# l = [["v1", 1], ["v2", 2], ["v1", 3], ["v2", 4, {"a": 1}]]
_, _, bins = client.operate(key, [ list_operations.list_get_by_value( "l", ["v2", aerospike.CDTWildcard()], aerospike.LIST_RETURN_VALUE )])# bins["l"] == [["v2", 2], ["v2", 4, {"a": 1}]]get_by_index_range(bin_name, index[, count], result_type[, context])Gets a range of count elements starting at a specified list index. The INVERTED flag may be used to get the elements not in a specified range.
The index and count can be any number, but the result may be an empty list if the specified range contains no elements.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
index | integer | Zero-based position, 0 being the first element. A negative index counts back from the end. |
count | integer | Number of elements to select. Optional; defaults to the rest of the collection. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
One or a list values, based on the return type. The elements returned may not be in index order.
The worst-case performance of getting elements by index range is 𝓞(M) for an ordered list with a persisted index, and 𝓞(N + M) for an ordered list without a persisted index or an unordered list, where M is the element count of the range, and N is the element count of the list. Requesting a RANK return type on an unordered list adds 𝓞(L*N). See List performance.
For [1, 3, 3, 7, 0] the VALUE range starting at index 2 and containing 3 elements gives back [3, 7, 0], while the INVERTED | VALUE of the same range gives back [1, 3].
// l = [1, 3, 3, 7, 0]
try (RecordStream rs = session.query(key) .bin("l").onListIndexRange(2, 3).getValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns [3, 7, 0]}
try (RecordStream rs = session.query(key) .bin("l").onListIndexRange(2, 3).getAllOtherValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns [1, 3]}# l = [1, 3, 3, 7, 0]
stream = session.query(key).bin("l").on_list_index_range(2, 3).get_values().execute()# returns [3, 7, 0]
stream = (session.query(key).bin("l").on_list_index_range(2, 3) .get_all_other_values().execute())# returns [1, 3]// Requires: use aerospike::operations::lists::{self, InvertedListReturn, ListReturnType};// l = [1, 3, 3, 7, 0]
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_index_range_count("l", 2, 3, ListReturnType::Values)]).await?;// returns [3, 7, 0]
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_index_range_count("l", 2, 3, InvertedListReturn(ListReturnType::Values))]).await?;// returns [1, 3]// l = [1, 3, 3, 7, 0]
Record record = client.Operate(null, key, ListOperation.GetByIndexRange("l", 2, 3, ListReturnType.VALUE));// returns [3, 7, 0]
record = client.Operate(null, key, ListOperation.GetByIndexRange("l", 2, 3, ListReturnType.VALUE | ListReturnType.INVERTED));// returns [1, 3]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// l = [1, 3, 3, 7, 0]
record, err := client.Operate(nil, key, as.ListGetByIndexRangeCountOp("l", 2, 3, as.ListReturnTypeValue),)// record.Bins["l"] == [3, 7, 0]
record, err = client.Operate(nil, key, as.ListGetByIndexRangeCountOp("l", 2, 3, as.ListReturnTypeValue|as.ListReturnTypeInverted),)// record.Bins["l"] == [1, 3]// l = [1, 3, 3, 7, 0]
const lists = Aerospike.lists
let result = await client.operate(key, [ lists.getByIndexRange('l', 2, 3).andReturn(lists.returnType.VALUE)])// result.bins.l == [3, 7, 0]
result = await client.operate(key, [ lists.getByIndexRange('l', 2, 3) .invertSelection() .andReturn(lists.returnType.VALUE)])// result.bins.l == [1, 3]// l = [1, 3, 3, 7, 0]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_get_by_index_range(&ops, "l", NULL, 2, 3, AS_LIST_RETURN_VALUE);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "l" == [3, 7, 0]
as_operations ops2;as_operations_inita(&ops2, 1);as_operations_list_get_by_index_range(&ops2, "l", NULL, 2, 3, AS_LIST_RETURN_VALUE | AS_LIST_RETURN_INVERTED);
as_record* rec2 = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops2, &rec2);// rec2 bins "l" == [1, 3]// l = [1, 3, 3, 7, 0]
Record record = client.operate(null, key, ListOperation.getByIndexRange("l", 2, 3, ListReturnType.VALUE));// returns [3, 7, 0]
record = client.operate(null, key, ListOperation.getByIndexRange("l", 2, 3, ListReturnType.VALUE | ListReturnType.INVERTED));// returns [1, 3]# l = [1, 3, 3, 7, 0]
_, _, bins = client.operate(key, [ list_operations.list_get_by_index_range("l", 2, aerospike.LIST_RETURN_VALUE, 3)])# bins["l"] == [3, 7, 0]
_, _, bins = client.operate(key, [ list_operations.list_get_by_index_range( "l", 2, aerospike.LIST_RETURN_VALUE, 3, inverted=True)])# bins["l"] == [1, 3]get_by_index(bin_name, index, result_type[, context])Gets the element at the specified list index. The index must be a number between 0 and N-1, where N is the length of the list. The index can also be a negative number, with -1 being the last element by index position.
On an ordered list this operation with a VALUE return type will be the same as a list get_by_rank operation.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
index | integer | Zero-based position, 0 being the first element. A negative index counts back from the end. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
A single result, based on the return type.
An Operation Not Applicable error (code 26) when trying to get an inaccessible index.
The worst-case performance of getting the element by index is 𝓞(1) for an ordered list with a persisted index, and 𝓞(N) for an ordered list without a persisted index or an unordered list.
[1, 3, 3, 7, 0] modified with set_order to ORDERED will turn into [0, 1, 3, 3, 7].
The value of the element at index -1 is 7, the rank at -1 is 7.
The value of the element at index 2 is 3, the element with rank 2 is 3.
// l = [0, 1, 3, 3, 7] (ORDERED)
try (RecordStream rs = session.query(key) .bin("l").onListIndex(2).getValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 3}
try (RecordStream rs = session.query(key) .appendOperations(ListOperation.getByIndex("l", 2, ListReturnType.RANK)) .execute()) { Record rec = rs.next().recordOrThrow(); // returns 2}
try (RecordStream rs = session.query(key) .bin("l").onListIndex(-1).getValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 7}# l = [0, 1, 3, 3, 7] (ORDERED)
stream = session.query(key).bin("l").on_list_index(2).get_values().execute()# returns 3
stream = session.query(key).bin("l").on_list_index(2).get_ranks().execute()# returns 2
stream = session.query(key).bin("l").on_list_index(-1).get_values().execute()# returns 7// Requires: use aerospike::operations::lists::{self, ListReturnType};// l = [0, 1, 3, 3, 7] (ORDERED)
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_index("l", 2, ListReturnType::Values)]).await?;// returns 3
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_index("l", 2, ListReturnType::Rank)]).await?;// returns 2
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_index("l", -1, ListReturnType::Values)]).await?;// returns 7// l = [0, 1, 3, 3, 7] (ORDERED)
Record record = client.Operate(null, key, ListOperation.GetByIndex("l", 2, ListReturnType.VALUE));// returns 3
record = client.Operate(null, key, ListOperation.GetByIndex("l", 2, ListReturnType.RANK));// returns 2
record = client.Operate(null, key, ListOperation.GetByIndex("l", -1, ListReturnType.VALUE));// returns 7// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// l = [0, 1, 3, 3, 7] (ORDERED)
record, err := client.Operate(nil, key, as.ListGetByIndexOp("l", 2, as.ListReturnTypeValue),)// record.Bins["l"] == 3
record, err = client.Operate(nil, key, as.ListGetByIndexOp("l", 2, as.ListReturnTypeRank),)// record.Bins["l"] == 2
record, err = client.Operate(nil, key, as.ListGetByIndexOp("l", -1, as.ListReturnTypeValue),)// record.Bins["l"] == 7// l = [0, 1, 3, 3, 7] (ORDERED)
const lists = Aerospike.lists
let result = await client.operate(key, [ lists.getByIndex('l', 2).andReturn(lists.returnType.VALUE)])// result.bins.l == 3
result = await client.operate(key, [ lists.getByIndex('l', 2).andReturn(lists.returnType.RANK)])// result.bins.l == 2
result = await client.operate(key, [ lists.getByIndex('l', -1).andReturn(lists.returnType.VALUE)])// result.bins.l == 7// l = [0, 1, 3, 3, 7] (ORDERED)
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_get_by_index(&ops, "l", NULL, 2, AS_LIST_RETURN_VALUE);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "l" == 3
as_operations ops_rank;as_operations_inita(&ops_rank, 1);as_operations_list_get_by_index(&ops_rank, "l", NULL, 2, AS_LIST_RETURN_RANK);
as_record* rec_rank = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops_rank, &rec_rank);// rec_rank bins "l" == 2
as_operations ops2;as_operations_inita(&ops2, 1);as_operations_list_get_by_index(&ops2, "l", NULL, -1, AS_LIST_RETURN_VALUE);
as_record* rec2 = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops2, &rec2);// rec2 bins "l" == 7// l = [0, 1, 3, 3, 7] (ORDERED)
Record record = client.operate(null, key, ListOperation.getByIndex("l", 2, ListReturnType.VALUE));// returns 3
record = client.operate(null, key, ListOperation.getByIndex("l", 2, ListReturnType.RANK));// returns 2
record = client.operate(null, key, ListOperation.getByIndex("l", -1, ListReturnType.VALUE));// returns 7# l = [0, 1, 3, 3, 7] (ORDERED)
_, _, bins = client.operate(key, [ list_operations.list_get_by_index("l", 2, aerospike.LIST_RETURN_VALUE)])# bins["l"] == 3
_, _, bins = client.operate(key, [ list_operations.list_get_by_index("l", 2, aerospike.LIST_RETURN_RANK)])# bins["l"] == 2
_, _, bins = client.operate(key, [ list_operations.list_get_by_index("l", -1, aerospike.LIST_RETURN_VALUE)])# bins["l"] == 7get_by_rank_range(bin_name, rank[, count], result_type[, context])Gets a range of count elements starting at a specified rank. The INVERTED flag may be used to get the elements not in a specified range.
The rank and count can be any number, but the result may be an empty list if the specified range contains no elements.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
rank | integer | Zero-based rank in value order, 0 being the smallest. A negative rank counts back from the largest. |
count | integer | Number of elements to select. Optional; defaults to the rest of the collection. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
One or a list of values, based on the return type. The elements returned may not be in rank order.
The worst-case performance of getting elements by rank range is 𝓞(M) for an ordered list with a persisted index. An ordered list without a persisted index has a 𝓞(N + M), where M is the element count of the range, and N is the element count of the list. An unordered list has a 𝓞(R log N + N).
For [1, 3, 2, 7, 0] the VALUE range starting at rank 2 and containing 2 elements gives back 2 and 3, while the INVERTED | VALUE of the same range gives back 0, 1 and 7, both in no guaranteed order.
// l = [1, 3, 2, 7, 0]
try (RecordStream rs = session.query(key) .bin("l").onListRankRange(2, 2).getValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 2 and 3, in no guaranteed order}
try (RecordStream rs = session.query(key) .bin("l").onListRankRange(2, 2).getAllOtherValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 0, 1 and 7, in no guaranteed order}# l = [1, 3, 2, 7, 0]
stream = session.query(key).bin("l").on_list_rank_range(2, 2).get_values().execute()# returns 2 and 3, in no guaranteed order
stream = (session.query(key).bin("l").on_list_rank_range(2, 2) .get_all_other_values().execute())# returns 0, 1 and 7, in no guaranteed order// Requires: use aerospike::operations::lists::{self, InvertedListReturn, ListReturnType};// l = [1, 3, 2, 7, 0]
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_rank_range_count("l", 2, 2, ListReturnType::Values)]).await?;// returns 2 and 3, in no guaranteed order
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_rank_range_count("l", 2, 2, InvertedListReturn(ListReturnType::Values))]).await?;// returns 0, 1 and 7, in no guaranteed order// l = [1, 3, 2, 7, 0]
Record record = client.Operate(null, key, ListOperation.GetByRankRange("l", 2, 2, ListReturnType.VALUE));// returns 2 and 3, in no guaranteed order
record = client.Operate(null, key, ListOperation.GetByRankRange("l", 2, 2, ListReturnType.VALUE | ListReturnType.INVERTED));// returns 0, 1 and 7, in no guaranteed order// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// l = [1, 3, 2, 7, 0]
record, err := client.Operate(nil, key, as.ListGetByRankRangeCountOp("l", 2, 2, as.ListReturnTypeValue),)// record.Bins["l"] holds 2 and 3, in no guaranteed order
record, err = client.Operate(nil, key, as.ListGetByRankRangeCountOp("l", 2, 2, as.ListReturnTypeValue|as.ListReturnTypeInverted),)// record.Bins["l"] holds 0, 1 and 7, in no guaranteed order// l = [1, 3, 2, 7, 0]
const lists = Aerospike.lists
let result = await client.operate(key, [ lists.getByRankRange('l', 2, 2).andReturn(lists.returnType.VALUE)])// result.bins.l holds 2 and 3, in no guaranteed order
result = await client.operate(key, [ lists.getByRankRange('l', 2, 2) .invertSelection() .andReturn(lists.returnType.VALUE)])// result.bins.l holds 0, 1 and 7, in no guaranteed order// l = [1, 3, 2, 7, 0]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_get_by_rank_range(&ops, "l", NULL, 2, 2, AS_LIST_RETURN_VALUE);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "l" holds 2 and 3, in no guaranteed order
as_operations ops2;as_operations_inita(&ops2, 1);as_operations_list_get_by_rank_range(&ops2, "l", NULL, 2, 2, AS_LIST_RETURN_VALUE | AS_LIST_RETURN_INVERTED);
as_record* rec2 = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops2, &rec2);// rec2 bins "l" holds 0, 1 and 7, in no guaranteed order// l = [1, 3, 2, 7, 0]
Record record = client.operate(null, key, ListOperation.getByRankRange("l", 2, 2, ListReturnType.VALUE));// returns 2 and 3, in no guaranteed order
record = client.operate(null, key, ListOperation.getByRankRange("l", 2, 2, ListReturnType.VALUE | ListReturnType.INVERTED));// returns 0, 1 and 7, in no guaranteed order# l = [1, 3, 2, 7, 0]
_, _, bins = client.operate(key, [ list_operations.list_get_by_rank_range("l", 2, aerospike.LIST_RETURN_VALUE, 2)])# bins["l"] holds 2 and 3, in no guaranteed order
_, _, bins = client.operate(key, [ list_operations.list_get_by_rank_range( "l", 2, aerospike.LIST_RETURN_VALUE, 2, inverted=True)])# bins["l"] holds 0, 1 and 7, in no guaranteed orderget_by_rank(bin_name, rank, result_type[, context])Gets the element with the specified rank order. The rank must be a number between 0 (lowest rank) and N-1 (highest rank), where N is the length of the list. The rank can also be a negative number, with -1 being the element with the highest rank.
On an ordered list this operation with a VALUE return type will be the same as a list get_by_index operation, (see this example).
Whether the list is unordered or ordered, get_by_rank will return the same elements, based on the ordering rules. The performance of ‘by rank’ operations is better on an ordered list than an unordered one.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
rank | integer | Zero-based rank in value order, 0 being the smallest. A negative rank counts back from the largest. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
A single result, based on the return type.
An Operation Not Applicable error (code 26) when trying to get an inaccessible rank.
The worst-case performance of getting an element by rank is 𝓞(1) for an ordered list with a persisted index, 𝓞(N) for an ordered list without a persisted index, and 𝓞(R log N + N) for an unordered list.
For [30, 10, 50, 20, 40] the element at rank 0 is 10 (lowest value), and the element at rank -1 is 50 (highest value).
// l = [30, 10, 50, 20, 40]
try (RecordStream rs = session.query(key) .bin("l").onListRank(0).getValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 10 (lowest rank)}
try (RecordStream rs = session.query(key) .bin("l").onListRank(-1).getValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 50 (highest rank)}
try (RecordStream rs = session.query(key) .appendOperations(ListOperation.getByRank("l", -1, ListReturnType.INDEX)) .execute()) { Record rec = rs.next().recordOrThrow(); // returns 2}# l = [30, 10, 50, 20, 40]
stream = session.query(key).bin("l").on_list_rank(0).get_values().execute()# returns 10 (lowest rank)
stream = session.query(key).bin("l").on_list_rank(-1).get_values().execute()# returns 50 (highest rank)
stream = session.query(key).bin("l").on_list_rank(-1).get_indexes().execute()# returns 2// Requires: use aerospike::operations::lists::{self, ListReturnType};// l = [30, 10, 50, 20, 40]
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_rank("l", 0, ListReturnType::Values)]).await?;// returns 10 (lowest rank)
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_rank("l", -1, ListReturnType::Values)]).await?;// returns 50 (highest rank)
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_rank("l", -1, ListReturnType::Index)]).await?;// returns 2// l = [30, 10, 50, 20, 40]
Record record = client.Operate(null, key, ListOperation.GetByRank("l", 0, ListReturnType.VALUE));// returns 10
record = client.Operate(null, key, ListOperation.GetByRank("l", -1, ListReturnType.VALUE));// returns 50
record = client.Operate(null, key, ListOperation.GetByRank("l", -1, ListReturnType.INDEX));// returns 2// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// l = [30, 10, 50, 20, 40]
record, err := client.Operate(nil, key, as.ListGetByRankOp("l", 0, as.ListReturnTypeValue),)// record.Bins["l"] == 10
record, err = client.Operate(nil, key, as.ListGetByRankOp("l", -1, as.ListReturnTypeValue),)// record.Bins["l"] == 50
record, err = client.Operate(nil, key, as.ListGetByRankOp("l", -1, as.ListReturnTypeIndex),)// record.Bins["l"] == 2// l = [30, 10, 50, 20, 40]
const lists = Aerospike.lists
let result = await client.operate(key, [ lists.getByRank('l', 0).andReturn(lists.returnType.VALUE)])// result.bins.l == 10
result = await client.operate(key, [ lists.getByRank('l', -1).andReturn(lists.returnType.VALUE)])// result.bins.l == 50
result = await client.operate(key, [ lists.getByRank('l', -1).andReturn(lists.returnType.INDEX)])// result.bins.l == 2// l = [30, 10, 50, 20, 40]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_get_by_rank(&ops, "l", NULL, 0, AS_LIST_RETURN_VALUE);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "l" == 10
as_operations ops2;as_operations_inita(&ops2, 1);as_operations_list_get_by_rank(&ops2, "l", NULL, -1, AS_LIST_RETURN_VALUE);
as_record* rec2 = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops2, &rec2);// rec2 bins "l" == 50
as_operations ops3;as_operations_inita(&ops3, 1);as_operations_list_get_by_rank(&ops3, "l", NULL, -1, AS_LIST_RETURN_INDEX);
as_record* rec3 = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops3, &rec3);// rec3 bins "l" == 2// l = [30, 10, 50, 20, 40]
Record record = client.operate(null, key, ListOperation.getByRank("l", 0, ListReturnType.VALUE));// returns 10 (lowest rank)
record = client.operate(null, key, ListOperation.getByRank("l", -1, ListReturnType.VALUE));// returns 50 (highest rank)
record = client.operate(null, key, ListOperation.getByRank("l", -1, ListReturnType.INDEX));// returns 2# l = [30, 10, 50, 20, 40]
_, _, bins = client.operate(key, [ list_operations.list_get_by_rank("l", 0, aerospike.LIST_RETURN_VALUE)])# bins["l"] == 10
_, _, bins = client.operate(key, [ list_operations.list_get_by_rank("l", -1, aerospike.LIST_RETURN_VALUE)])# bins["l"] == 50
_, _, bins = client.operate(key, [ list_operations.list_get_by_rank("l", -1, aerospike.LIST_RETURN_INDEX)])# bins["l"] == 2get_by_value_range(bin_name, value_begin, value_end, result_type[, context])Gets the list elements that sort into the interval between valueStart (inclusive) and valueStop (exclusive). The INVERTED flag may be used to get the elements outside this interval.
Whether the list is unordered or ordered, get_by_value_interval will return the same elements, based on the ordering rules. The performance of ‘by value’ operations is better on an ordered list than an unordered one.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
value_begin | any | Lowest value to match, inclusive. |
value_end | any | Upper bound on the value, exclusive. Omit it to match everything from |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
Zero, one or a list of values, based on the return type. The elements returned may not be in index order.
The worst-case performance of getting elements in a value interval is 𝓞(log N + M) for an ordered list with a persisted index, 𝓞(log N + N) for an ordered list without a persisted index, and 𝓞(N + M) for an unordered list, where M is the number of items in the parameter list and N is the number of items already in the list.
Get the list elements in the interval between two scalar values. See the code sample below.
It is common to model complex data in Aerospike as a list of tuples, each element a list, where the index order carries meaning. For an example, see Aerospike Modeling: IoT Sensors.
This modeling relies on the ordering rules that apply to list elements. Ordered pairs sort into
[1, NIL] < [1, 1] < [1, 1, 2] < [1, 2] < [1, '1'] < [1, 1.0] < [1, INF]
Take the list of ordered pairs, [[100, 1], [101, 2], [102, 3], [103, 4], [104, 5]] and the following intervals:
valueStart: [101, NIL], valueStop: [103, NIL]
Iterating over the elements we check if [101, NIL] <= value < [103, NIL]. This is true for the elements [101, 2] and [102, 3]. The element [103, 4] is not in this interval, because its order is higher than [103, NIL]. The comparison starts with the 0th index values, in this case both are 103. Next the 1st index position values are compared, and NIL is lower than 3 (actually its order is lower than any value).
valueStart: [101, NIL], valueStop: [103, INF]
The elements [101, 2] and [102, 3] are obviously in the interval. The element [103, 4] is also in this interval, because its order is lower than [103, INF]. The comparison starts with the 0th index values, in this case both are 103. Next the 1st index position values are compared, and INF is higher than 3 (actually its order is higher than any value).
valueStart: [101, INF], valueStop: [103, INF]
The elements [102, 3] and [103, 4] are in the interval. The element [101, 2] is not in this interval, because its order is lower than [101, INF].
// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// get all elements in the interval [2, 4)try (RecordStream rs = session.query(key) .bin("l").onListValueRange(2, 4).getValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns [2, 3, 3, 2]}# l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
# get all elements in the interval [2, 4)stream = session.query(key).bin("l").on_list_value_range(2, 4).get_values().execute()# returns [2, 3, 3, 2]// Requires: use aerospike::operations::lists::{self, ListReturnType};// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// get all elements in the interval [2, 4)let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_value_range("l", as_val!(2), as_val!(4), ListReturnType::Values)]).await?;// returns [2, 3, 3, 2]// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// get all elements in the interval [2, 4)Record record = client.Operate(null, key, ListOperation.GetByValueRange("l", Value.Get(2), Value.Get(4), ListReturnType.VALUE));// returns [2, 3, 3, 2]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// get all elements in the interval [2, 4)record, err := client.Operate(nil, key, as.ListGetByValueRangeOp("l", 2, 4, as.ListReturnTypeValue),)// record.Bins["l"] == [2, 3, 3, 2]// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// get all elements in the interval [2, 4)const lists = Aerospike.lists
const result = await client.operate(key, [ lists.getByValueRange('l', 2, 4).andReturn(lists.returnType.VALUE)])// result.bins.l == [2, 3, 3, 2]// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// get all elements in the interval [2, 4)as_integer begin;as_integer_init(&begin, 2);as_integer end;as_integer_init(&end, 4);
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_get_by_value_range(&ops, "l", NULL, (as_val*)&begin, (as_val*)&end, AS_LIST_RETURN_VALUE);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "l" == [2, 3, 3, 2]// l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
// get all elements in the interval [2, 4)Record record = client.operate(null, key, ListOperation.getByValueRange("l", Value.get(2), Value.get(4), ListReturnType.VALUE));// returns [2, 3, 3, 2]# l = [1, 2, 3, 4, 5, 4, 3, 2, 1]
# get all elements in the interval [2, 4)_, _, bins = client.operate(key, [ list_operations.list_get_by_value_range( "l", aerospike.LIST_RETURN_VALUE, 2, 4)])# bins["l"] == [2, 3, 3, 2]get_by_value_rel_rank_range(bin_name, value, rank[, count], result_type[, context])Gets a range of count elements starting at a rank offset from the relative rank of the given value. The INVERTED flag may be used to get the elements not in this range.
The value can be anything, not necessarily a value that exists in the list. The rank and count can be any number, but the result may be an empty list if the specified range contains no elements.
The relative rank of the value compared to the current list follows the ordering rules.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
value | any | Value that |
rank | integer | Zero-based rank in value order, 0 being the smallest. A negative rank counts back from the largest. |
count | integer | Number of elements to select. Optional; defaults to the rest of the collection. |
result_type | integer literal | Which form the result takes — a count, an index, a rank, a value, or nothing. See Return types. |
context | Context 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 list. |
Zero, one or a list of values, based on the return type. The elements returned may not be in index order.
The worst-case performance of getting elements by relative rank range is 𝓞(M + log N) for an ordered list with a persisted index. An ordered list without a persisted index has a 𝓞(N + M + log N), where M is the element count of the range, and N is the element count of the list. An unordered list has a 𝓞(R log N + N), with R for rank.
origin = relative-rank(_value_) # compared to the current list elementsr = rank(element)
Get all elements in the range where(r >= (origin + _rank_)) and (r < (origin + _rank_ + _count_))For [0, 3, 9, 12, 15] a value of 5 would rank between 3 and 9, relative to the current list. A rank of -1 from there would select 3 as the starting point of the range, and then the count would select the elements. So a count of 3 would return the range 3, 9 and 12.
// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → start at rank 1, get 3 elements
try (RecordStream rs = session.query(key) .bin("scores").onListValueRelativeRankRange(5, -1, 3).getValues() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 3, 9 and 12, in no guaranteed order}# scores = [0, 3, 9, 12, 15]# Relative rank of value 5: between 3 and 9 (rank position 2)# rank offset -1, count 3 → start at rank 1, get 3 elements
stream = (session.query(key).bin("scores") .on_list_value_relative_rank_range(5, -1, 3).get_values().execute())# returns 3, 9 and 12, in no guaranteed order// Requires: use aerospike::operations::lists::{self, ListReturnType};// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → start at rank 1, get 3 elements
let record = client.operate(&WritePolicy::default(), &key, &[lists::get_by_value_relative_rank_range_count("scores", as_val!(5), -1, 3, ListReturnType::Values)]).await?;// returns 3, 9 and 12, in no guaranteed order// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → start at rank 1, get 3 elements
Record record = client.Operate(null, key, ListOperation.GetByValueRelativeRankRange("scores", Value.Get(5), -1, 3, ListReturnType.VALUE));// returns 3, 9 and 12, in no guaranteed order// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → start at rank 1, get 3 elements
record, err := client.Operate(nil, key, as.ListGetByValueRelativeRankRangeCountOp("scores", 5, -1, 3, as.ListReturnTypeValue),)// record.Bins["scores"] holds 3, 9 and 12, in no guaranteed order// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → start at rank 1, get 3 elements
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.getByValueRelRankRange('scores', 5, -1, 3) .andReturn(lists.returnType.VALUE)])// result.bins.scores holds 3, 9 and 12, in no guaranteed order// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → start at rank 1, get 3 elements
as_integer val;as_integer_init(&val, 5);
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_get_by_value_rel_rank_range(&ops, "scores", NULL, (as_val*)&val, -1, 3, AS_LIST_RETURN_VALUE);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "scores" holds 3, 9 and 12, in no guaranteed order// scores = [0, 3, 9, 12, 15]// Relative rank of value 5: between 3 and 9 (rank position 2)// rank offset -1, count 3 → start at rank 1, get 3 elements
Record record = client.operate(null, key, ListOperation.getByValueRelativeRankRange("scores", Value.get(5), -1, 3, ListReturnType.VALUE));// returns 3, 9 and 12, in no guaranteed order# scores = [0, 3, 9, 12, 15]# Relative rank of value 5: between 3 and 9 (rank position 2)# rank offset -1, count 3 → start at rank 1, get 3 elements
_, _, bins = client.operate(key, [ list_operations.list_get_by_value_rank_range_relative( "scores", 5, -1, aerospike.LIST_RETURN_VALUE, 3)])# bins["scores"] holds 3, 9 and 12, in no guaranteed orderjoin(bin_name[, separator][, context])Concatenates the string elements of a list into a single string and returns it, without modifying the list. An optional separator is placed between consecutive elements; omit it to concatenate with nothing between them. An optional context targets a nested list.
Every element must be a string. An empty list returns an empty string, and a single-element list returns that element with no separator applied.
This is the inverse of the string split operation. join is a List operation rather than a string operation, because it reads a list bin.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
separator | string | String placed between elements. Omit it to join them with nothing in between. |
context | Context 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 list. |
A single string holding the concatenated elements.
A Parameter error (code 4) when any element is not a string, when the separator is not a string, when the bin does not hold a valid list, or when the joined result would exceed the server’s size limit. The Java and C# clients name this code PARAMETER_ERROR; the C client names it AEROSPIKE_ERR_REQUEST_INVALID. They are the same code.
All but the separator case carry error-detail subcode AS_SUB_PARAM_STRING_OP_PARAMS_INVALID (6) and name the cause in the message, identifying the offending element by index for a non-string element. A non-string separator reports no subcode. See error detail subcodes for the full list.
The worst-case performance of joining the list is 𝓞(N), where N is the number of elements.
Given tags = ["red", "green", "blue"], calling join("tags", ", ") returns "red, green, blue".
Calling join("tags") with no separator returns "redgreenblue".
An empty list returns an empty string rather than an error, so a join over a list that may be empty needs no guard. A single-element list returns that element unchanged, because a separator is only placed between elements.
// tags = ["red", "green", "blue"]
try (RecordStream rs = session.query(key) .bin("tags").listJoin(", ") .execute()) { Record rec = rs.next().recordOrThrow(); // returns "red, green, blue"}# tags = ["red", "green", "blue"]
stream = session.query(key).bin("tags").list_join(", ").execute()# returns "red, green, blue"// Requires: use aerospike::operations::lists::{self};// tags = ["red", "green", "blue"]
let record = client.operate(&WritePolicy::default(), &key, &[lists::join_by_separator("tags", ", ")]).await?;// returns "red, green, blue"// tags = ["red", "green", "blue"]
Record record = client.Operate(null, key, ListOperation.Join("tags", ", "));// returns "red, green, blue"// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// tags = ["red", "green", "blue"]
record, err := client.Operate(nil, key, as.ListJoinBySeparatorOp("tags", ", "),)// record.Bins["tags"] == "red, green, blue"// tags = ["red", "green", "blue"]
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.joinSeparator('tags', ', ')])// result.bins.tags == "red, green, blue"// tags = ["red", "green", "blue"]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_join_separator(&ops, "tags", NULL, ", ");
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "tags" == "red, green, blue"// tags = ["red", "green", "blue"]
Record record = client.operate(null, key, ListOperation.join("tags", ", "));// returns "red, green, blue"# tags = ["red", "green", "blue"]
_, _, bins = client.operate(key, [ list_operations.list_join("tags", ", ")])# bins["tags"] == "red, green, blue"size(bin_name[, context])Gets the size of a list, optionally at a given subcontext.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
context | Context 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 list. |
Returns the count of elements in the list at the level specified.
The worst-case performance of getting the size of the list is 𝓞(1).
// scores = [10, 20, 30, 40, 50]
try (RecordStream rs = session.query(key) .bin("scores").listSize() .execute()) { Record rec = rs.next().recordOrThrow(); // returns 5}# scores = [10, 20, 30, 40, 50]
stream = session.query(key).bin("scores").list_size().execute()# returns 5// Requires: use aerospike::operations::lists::{self};// scores = [10, 20, 30, 40, 50]
let record = client.operate(&WritePolicy::default(), &key, &[lists::size("scores")]).await?;// returns 5// scores = [10, 20, 30, 40, 50]
Record record = client.Operate(null, key, ListOperation.Size("scores"));// returns 5// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// scores = [10, 20, 30, 40, 50]
record, err := client.Operate(nil, key, as.ListSizeOp("scores"),)// record.Bins["scores"] == 5// scores = [10, 20, 30, 40, 50]
const lists = Aerospike.lists
const result = await client.operate(key, [ lists.size('scores')])// result.bins.scores == 5// scores = [10, 20, 30, 40, 50]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_size(&ops, "scores", NULL);
as_record* rec = NULL;aerospike_key_operate(&as, &err, NULL, &key, &ops, &rec);// rec bins "scores" == 5// scores = [10, 20, 30, 40, 50]
Record record = client.operate(null, key, ListOperation.size("scores"));// returns 5# scores = [10, 20, 30, 40, 50]
_, _, bins = client.operate(key, [ list_operations.list_size("scores")])# bins["scores"] == 5Set operations
set_order(bin_name, order[, context])Modifies the order of an existing list. Order can be UNORDERED (default) or ORDERED. An optional persistIndex flag stores the offset index on disk alongside the list for O(1) index access on subsequent operations.
Once set, both the order and persist-index flags are preserved across all subsequent list operations until changed by another set_order() call. The persist-index flag applies only to top-level lists.
| Name | Type | Description |
|---|---|---|
bin_name | string | Name of the bin to operate on. |
order | integer literal | List order to set: |
context | Context 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 list. |
null
The set_order operation does nothing when called on an already ordered list or on an ordered-to-unordered transition. The worst-case performance of modifying an unordered list to an ordered one is 𝓞(N log N).
[1, 3, [3, 7], 0, [3, 2]] modified with set_order to ORDERED will turn into [0, 1, 3, [3, 2], [3, 7]], because a list has higher ranking order than integers, and the list elements are compared by index when sorted.
// l = [1, 3, [3, 7], 0, [3, 2]]
try (RecordStream rs = session.upsert(key) .bin("l").listSetOrder(ListOrder.ORDERED) .execute()) { Record rec = rs.next().recordOrThrow();}// l == [0, 1, 3, [3, 2], [3, 7]]# l = [1, 3, [3, 7], 0, [3, 2]]
session.upsert(key).bin("l").list_set_order(ListOrderType.ORDERED).execute()# l == [0, 1, 3, [3, 2], [3, 7]]// Requires: use aerospike::operations::lists::{self, ListOrderType};// l = [1, 3, [3, 7], 0, [3, 2]]
client.operate(&WritePolicy::default(), &key, &[lists::set_order("l", ListOrderType::Ordered)]).await?;// l == [0, 1, 3, [3, 2], [3, 7]]// l = [1, 3, [3, 7], 0, [3, 2]]
client.Operate(null, key, ListOperation.SetOrder("l", ListOrder.ORDERED));// l == [0, 1, 3, [3, 2], [3, 7]]// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// l = [1, 3, [3, 7], 0, [3, 2]]
_, err := client.Operate(nil, key, as.ListSetOrderOp("l", as.ListOrderOrdered),)// l == [0, 1, 3, [3, 2], [3, 7]]// l = [1, 3, [3, 7], 0, [3, 2]]
const lists = Aerospike.lists
await client.operate(key, [ lists.setOrder('l', lists.order.ORDERED)])// l == [0, 1, 3, [3, 2], [3, 7]]// l = [1, 3, [3, 7], 0, [3, 2]]
as_operations ops;as_operations_inita(&ops, 1);as_operations_list_set_order(&ops, "l", NULL, AS_LIST_ORDERED);
aerospike_key_operate(&as, &err, NULL, &key, &ops, NULL);// l == [0, 1, 3, [3, 2], [3, 7]]// l = [1, 3, [3, 7], 0, [3, 2]]
client.operate(null, key, ListOperation.setOrder("l", ListOrder.ORDERED));// l == [0, 1, 3, [3, 2], [3, 7]]# l = [1, 3, [3, 7], 0, [3, 2]]
client.operate(key, [ list_operations.list_set_order("l", aerospike.LIST_ORDERED)])# l == [0, 1, 3, [3, 2], [3, 7]]