Sync Query Builders

Synchronous query and write-verb builders delegating to aio.operations.query.

class aerospike_sdk.sync.operations.query.SyncQueryBuilder[source]

Bases: _SyncWriteVerbs

Configure and run reads, queries, and write segments synchronously.

Every chain method forwards to QueryBuilder. execute() blocks on the owning loop manager and returns SyncRecordStream. Detailed parameter semantics (filters, policies, CDT, on_error) are documented on the async builder.

See also

QueryBuilder

__init__(async_client, namespace, set_name, loop_manager, query_builder=None)[source]

Attach or create an async QueryBuilder and the sync loop.

bins(bin_names)[source]

Specify which bins to retrieve.

Return type:

SyncQueryBuilder

bin(bin_name)[source]

Start a bin-level read operation.

Return type:

QueryBinBuilder[SyncQueryBuilder]

add_operation(op)[source]

Append a read operation produced by a bin or CDT builder.

Return type:

None

with_write_operations(operations)[source]

Attach scalar write operations for a background dataset task.

Return type:

SyncQueryBuilder

with_no_bins()[source]

Specify that no bins should be read (header-only query).

Return type:

SyncQueryBuilder

filter(filter_obj)[source]

Add a filter to the query.

Return type:

SyncQueryBuilder

filter_expression(expression)[source]

Set a FilterExpression for server-side filtering.

Return type:

SyncQueryBuilder

where(expression)[source]
Overloads:
  • self, expression (str) → SyncQueryBuilder

  • self, expression (FilterExpression) → SyncQueryBuilder

Set the query filter from an AEL string or FilterExpression.

with_policy(policy)[source]

Set the query policy.

Return type:

SyncQueryBuilder

with_read_policy(policy)[source]

Set the read policy (for single key or batch key queries).

Return type:

SyncQueryBuilder

partition(partition_filter)[source]

Set the partition filter.

Return type:

SyncQueryBuilder

on_partitions(*partition_ids)[source]

Set partitions to query by partition IDs.

Return type:

SyncQueryBuilder

on_partition(part_id)[source]

Target a specific partition for the query.

Return type:

SyncQueryBuilder

on_partition_range(start_incl, end_excl)[source]

Target a range of partitions for the query.

Return type:

SyncQueryBuilder

chunk_size(chunk_size)[source]

Set the chunk size for server-side streaming.

Return type:

SyncQueryBuilder

records_per_second(rps)[source]

Set the maximum records per second for the query.

Return type:

SyncQueryBuilder

max_records(max_records)[source]

Set the maximum number of records to return.

Return type:

SyncQueryBuilder

limit(limit)[source]

Set the maximum number of records to return (alias for max_records).

Return type:

SyncQueryBuilder

expected_duration(duration)[source]

Set the expected duration of the query.

Return type:

SyncQueryBuilder

with_hint(hint)[source]

Attach a query hint for secondary index selection or scheduling.

Forwards to with_hint().

Parameters:

hint (QueryHint) – A QueryHint instance.

Return type:

SyncQueryBuilder

Returns:

This builder for method chaining.

See also

QueryHint

with_index_context(index_context)[source]

Explicitly override the secondary index metadata used for filter generation.

Most applications do not need this method. The client automatically discovers and caches secondary index metadata in the background.

Parameters:

index_context (IndexContext) – Index metadata for the query’s namespace.

Return type:

SyncQueryBuilder

Returns:

This builder for method chaining.

replica(replica)[source]

Set the replica preference for the query.

Return type:

SyncQueryBuilder

base_policy(base_policy)[source]

Set the base policy for the query.

Return type:

SyncQueryBuilder

fail_on_filtered_out()[source]

Include filtered-out records in the stream with FILTERED_OUT code.

Return type:

SyncQueryBuilder

respond_all_keys()[source]

Return null for missing keys instead of omitting them.

Return type:

SyncQueryBuilder

default_where(expression)[source]
Overloads:
  • self, expression (str) → SyncQueryBuilder

  • self, expression (FilterExpression) → SyncQueryBuilder

Set a default filter for all chained operations that lack their own.

default_expire_record_after_seconds(seconds)[source]

Set a default TTL for all chained operations that lack their own.

Return type:

SyncQueryBuilder

default_never_expire()[source]

Set the default TTL to never expire (TTL = -1).

Return type:

SyncQueryBuilder

default_with_no_change_in_expiration()[source]

Set the default to preserve each record’s existing TTL (TTL = -2).

Return type:

SyncQueryBuilder

default_expiry_from_server_default()[source]

Set the default TTL to the namespace’s server default (TTL = 0).

Return type:

SyncQueryBuilder

query(arg1, *more_keys)[source]

Chain another query with new key(s) for batch/point stacking.

Return type:

SyncQueryBuilder

execute_background_task()[source]

Run a background write for this dataset query (see QueryBuilder).

Return type:

ExecuteTask

execute_udf_background_task(package_name, function_name, args=None)[source]

Run a background UDF for this dataset query (see QueryBuilder).

Return type:

ExecuteTask

execute(on_error=None)[source]

Run the configured query or write chain and block until the stream is ready.

Parameters:

on_error (Union[ErrorStrategy, Callable[[Key, int, AerospikeError], None], None]) – Same as execute() (ErrorStrategy or callback).

Return type:

SyncRecordStream

Returns:

SyncRecordStream.

See also

execute()

class aerospike_sdk.sync.operations.query.SyncWriteSegmentBuilder[source]

Bases: _SyncWriteVerbs

Synchronous multi-key write segment (mirrors WriteSegmentBuilder).

Bin scalars, CDT, expressions, and policies delegate to the embedded async segment; execute() returns SyncRecordStream.

__init__(wsb, loop_manager)[source]
bin(bin_name)[source]

Start a bin-level write operation.

Return type:

SyncWriteBinBuilder

add_operation(op)[source]

Append an operation (used by CDT action builders).

Return type:

None

put(bins)[source]

Set multiple bins at once.

Return type:

SyncWriteSegmentBuilder

set_bins(bins)[source]

Alias for put().

Return type:

SyncWriteSegmentBuilder

set_to(bin_name, value)[source]

Set a bin to value.

Return type:

SyncWriteSegmentBuilder

add(bin_name, value)[source]

Add a numeric value to a bin.

Return type:

SyncWriteSegmentBuilder

increment_by(bin_name, value)[source]

Alias for add().

Return type:

SyncWriteSegmentBuilder

get(bin_name)[source]

Read a bin value back within a write operate.

Return type:

SyncWriteSegmentBuilder

append(bin_name, value)[source]

Append a string to a bin.

Return type:

SyncWriteSegmentBuilder

prepend(bin_name, value)[source]

Prepend a string to a bin.

Return type:

SyncWriteSegmentBuilder

remove_bin(bin_name)[source]

Delete a bin from the record.

Return type:

SyncWriteSegmentBuilder

delete_record()[source]

Add a record-level delete to the current operate call.

Unlike delete() which targets a different key, this deletes the record being operated on as part of the same atomic operation.

Example:

stream = (
    session.upsert(key)
        .bin("name").get()
        .delete_record()
        .execute()
)
Return type:

SyncWriteSegmentBuilder

Returns:

This segment for chaining.

See also

delete(): Start a new delete segment for a key.

touch_record()[source]

Add a record-level touch to the current operate call.

Resets the record’s TTL as part of an atomic multi-operation call. Combine with expire_record_after_seconds() to set a new TTL.

Example:

stream = (
    session.upsert(key)
        .bin("score").get()
        .touch_record()
        .expire_record_after_seconds(120)
        .execute()
)
Return type:

SyncWriteSegmentBuilder

Returns:

This segment for chaining.

See also

touch(): Start a new touch segment for a key.

select_from(bin_name, expression, *, ignore_eval_failure=False)[source]

Read a computed value into a bin using an AEL expression.

Return type:

SyncWriteSegmentBuilder

insert_from(bin_name, expression, *, ignore_op_failure=False, ignore_eval_failure=False, delete_if_null=False)[source]

Write expression result only if bin does not already exist.

Return type:

SyncWriteSegmentBuilder

update_from(bin_name, expression, *, ignore_op_failure=False, ignore_eval_failure=False, delete_if_null=False)[source]

Write expression result only if bin already exists.

Return type:

SyncWriteSegmentBuilder

upsert_from(bin_name, expression, *, ignore_op_failure=False, ignore_eval_failure=False, delete_if_null=False)[source]

Write expression result, creating or overwriting the bin.

Return type:

SyncWriteSegmentBuilder

query(arg1, *more_keys)[source]

Finalize current write segment and start a read segment.

Return type:

SyncQueryBuilder

where(expression)[source]

Set a filter expression on the current write segment.

Return type:

SyncWriteSegmentBuilder

expire_record_after_seconds(seconds)[source]

Set the TTL on the current write segment.

Return type:

SyncWriteSegmentBuilder

never_expire()[source]

Set this record to never expire (TTL = -1).

Return type:

SyncWriteSegmentBuilder

with_no_change_in_expiration()[source]

Preserve the record’s existing TTL (TTL = -2).

Return type:

SyncWriteSegmentBuilder

expiry_from_server_default()[source]

Use the namespace’s default TTL for this record (TTL = 0).

Return type:

SyncWriteSegmentBuilder

ensure_generation_is(generation)[source]

Set expected generation for optimistic locking.

Return type:

SyncWriteSegmentBuilder

durably_delete()[source]

Enable durable delete on the current segment.

Return type:

SyncWriteSegmentBuilder

respond_all_keys()[source]

Include results for missing keys in the stream.

Return type:

SyncWriteSegmentBuilder

fail_on_filtered_out()[source]

Mark filtered-out records with FILTERED_OUT result code.

Return type:

SyncWriteSegmentBuilder

replace_only()[source]

Change the current segment to replace-if-exists semantics.

Return type:

SyncWriteSegmentBuilder

execute(on_error=None)[source]

Flush accumulated write operations and return a synchronous result stream.

Parameters:

on_error (Union[ErrorStrategy, Callable[[Key, int, AerospikeError], None], None]) – Same as SyncQueryBuilder.execute().

Return type:

SyncRecordStream

Returns:

SyncRecordStream.

See also

execute()

class aerospike_sdk.sync.operations.query.SyncWriteBinBuilder[source]

Bases: _SyncWriteVerbs

Synchronous wrapper for bin-level write operations.

Per-bin write builder that captures a bin name and delegates all operations to the parent SyncWriteSegmentBuilder. HyperLogLog and blob bit operations use hll_* and bit_* methods, matching WriteBinBuilder.

__init__(sync_segment, bin_name)[source]
set_to(value)[source]

Set the bin to value.

Parameters:

value (Any) – New value to store.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

add(value)[source]

Add a numeric value to the bin.

Parameters:

value (Any) – Numeric value to add.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

increment_by(value)[source]

Alias for add().

Parameters:

value (Any) – Numeric value to add.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

append(value)[source]

Append a string to the bin.

Parameters:

value (str) – String to append.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

prepend(value)[source]

Prepend a string to the bin.

Parameters:

value (str) – String to prepend.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

remove()[source]

Delete the bin from the record.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

get()[source]

Read the bin value back within a write operate.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_add(value, *, unique=False, bounded=False, no_fail=False)[source]

Add value to an ordered list (sorted insert).

Parameters:
  • value (Any) – Value to insert.

  • unique (bool) – Reject if the value already exists in the list.

  • bounded (bool) – Reject if index is beyond the current list bounds.

  • no_fail (bool) – Do not raise on write failures.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_append(value, *, unique=False, bounded=False, no_fail=False)[source]

Append value to the end of an unordered list.

Parameters:
  • value (Any) – Value to append.

  • unique (bool) – Reject if the value already exists in the list.

  • bounded (bool) – Reject if index is beyond the current list bounds.

  • no_fail (bool) – Do not raise on write failures.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

map_clear()[source]

Remove all entries from the map bin.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

map_size()[source]

Return the map element count (read within operate).

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

map_upsert_items(items, *, order=None, persist_index=False, no_fail=False, partial=False)[source]

Put multiple map entries (create or update each key).

Parameters:
  • items (Any) – Mapping or sequence of (key, value) pairs.

  • order (MapOrder | None) – Map key order for the policy.

  • persist_index (bool) – Maintain a persistent index on the map.

  • no_fail (bool) – Do not raise on write failures.

  • partial (bool) – Allow partial success for bulk operations.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

map_insert_items(items, *, order=None, persist_index=False, no_fail=False, partial=False)[source]

Put map entries only for keys that do not yet exist.

Parameters:
  • items (Any) – Mapping or sequence of (key, value) pairs.

  • order (MapOrder | None) – Map key order for the policy.

  • persist_index (bool) – Maintain a persistent index on the map.

  • no_fail (bool) – Do not raise on write failures.

  • partial (bool) – Allow partial success for bulk operations.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

map_update_items(items, *, order=None, persist_index=False, no_fail=False, partial=False)[source]

Update existing map entries only (no new keys).

Parameters:
  • items (Any) – Mapping or sequence of (key, value) pairs.

  • order (MapOrder | None) – Map key order for the policy.

  • persist_index (bool) – Maintain a persistent index on the map.

  • no_fail (bool) – Do not raise on write failures.

  • partial (bool) – Allow partial success for bulk operations.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

map_create(order)[source]

Create an empty map with the given key order.

Parameters:

order (MapOrder) – Key sort order for the map.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

map_set_policy(order)[source]

Set map sort order policy without changing entries.

Parameters:

order (MapOrder) – Key sort order to apply.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_clear()[source]

Remove all elements from the list bin.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_sort(flags=ListSortFlags.DEFAULT)[source]

Sort the list bin.

Parameters:

flags (ListSortFlags) – Sort behavior flags (default DEFAULT).

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_size()[source]

Return the list element count (read within operate).

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_append_items(items, *, unique=False, bounded=False, no_fail=False, partial=False)[source]

Append values to an unordered list.

Parameters:
  • items (Any) – Values to append.

  • unique (bool) – Reject items that already exist in the list.

  • bounded (bool) – Reject inserts beyond the current list bounds.

  • no_fail (bool) – Do not raise on write failures.

  • partial (bool) – Allow partial success for bulk operations.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_add_items(items, *, unique=False, bounded=False, no_fail=False, partial=False)[source]

Insert values into an ordered list (sorted positions).

Parameters:
  • items (Any) – Values to insert.

  • unique (bool) – Reject items that already exist in the list.

  • bounded (bool) – Reject inserts beyond the current list bounds.

  • no_fail (bool) – Do not raise on write failures.

  • partial (bool) – Allow partial success for bulk operations.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_create(order, *, pad=False, persist_index=False)[source]

Create an empty list with the given order.

Parameters:
  • order (ListOrderType) – Element ordering.

  • pad (bool) – If True, allow sparse indexes.

  • persist_index (bool) – If True, maintain a persistent index.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_set_order(order)[source]

Set list sort order without changing elements.

Parameters:

order (ListOrderType) – Sort order to apply.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_insert(index, value, *, unique=False, bounded=False, no_fail=False)[source]

Insert value at index in an unordered list.

Parameters:
  • index (int) – List index (0-based; negative counts from the end).

  • value (Any) – Element to insert.

  • unique (bool) – Reject if the value already exists in the list.

  • bounded (bool) – Reject if index is beyond the current list bounds.

  • no_fail (bool) – Do not raise on write failures.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_insert_items(index, items, *, unique=False, bounded=False, no_fail=False, partial=False)[source]

Insert a sequence of values starting at index.

Parameters:
  • index (int) – List index at which to insert the first element.

  • items (Sequence[Any]) – Values to insert in order.

  • unique (bool) – Reject items that already exist in the list.

  • bounded (bool) – Reject inserts beyond the current list bounds.

  • no_fail (bool) – Do not raise on write failures.

  • partial (bool) – Allow partial success for bulk operations.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_set(index, value)[source]

Replace the element at index with value.

Semantics match aerospike_sdk.aio.operations.query.WriteBinBuilder.list_set().

Parameters:
  • index (int) – List index (0-based; negative counts from the end).

  • value (Any) – New element value.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_increment(index, value=1)[source]

Add value to the numeric element at index (default increment is 1).

Semantics match aerospike_sdk.aio.operations.query.WriteBinBuilder.list_increment().

Parameters:
  • index (int) – List index (0-based; negative counts from the end).

  • value (int) – Amount to add; 1 uses a dedicated server path.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_remove(index)[source]

Remove the element at index.

Semantics match aerospike_sdk.aio.operations.query.WriteBinBuilder.list_remove().

Parameters:

index (int) – List index (0-based; negative counts from the end).

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_remove_range(index, count=None)[source]

Remove count elements starting at index, or all from index onward.

Semantics match aerospike_sdk.aio.operations.query.WriteBinBuilder.list_remove_range().

Parameters:
  • index (int) – Starting list index.

  • count (Optional[int]) – Number of elements to remove; None removes through the end.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_pop(index)[source]

Remove and return the element at index (read in the operate result).

Semantics match aerospike_sdk.aio.operations.query.WriteBinBuilder.list_pop().

Parameters:

index (int) – List index (0-based; negative counts from the end).

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_pop_range(index, count=None)[source]

Pop count elements from index, or from index through the end.

Semantics match aerospike_sdk.aio.operations.query.WriteBinBuilder.list_pop_range().

Parameters:
  • index (int) – Starting list index.

  • count (Optional[int]) – Number of elements; None pops through the end.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

list_trim(index, count)[source]

Keep only count elements starting at index; remove the rest.

Semantics match aerospike_sdk.aio.operations.query.WriteBinBuilder.list_trim().

Parameters:
  • index (int) – Starting list index of the range to keep.

  • count (int) – Number of elements to keep.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

hll_init(index_bit_count, min_hash_bit_count=-1, flags=0)[source]

Initialize an empty HyperLogLog sketch in this bin.

Semantics match aerospike_sdk.aio.operations.query.WriteBinBuilder.hll_init(). The synchronous API returns SyncWriteSegmentBuilder and uses SyncWriteSegmentBuilder.execute() instead of await.

Example::

session.upsert(key).bin(“visitors”).hll_init(12)

Parameters:
  • index_bit_count (int) – Same as the async method.

  • min_hash_bit_count (int) – Same as the async method.

  • flags (int) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

hll_add(values, index_bit_count=-1, min_hash_bit_count=-1, flags=0)[source]

Add distinct values to the HyperLogLog sketch in this bin.

Semantics match aerospike_sdk.aio.operations.query.WriteBinBuilder.hll_add().

Example::

session.upsert(key).bin(“visitors”).hll_add([“user-1”, “user-2”])

Parameters:
  • values (Sequence[Any]) – Same as the async method.

  • index_bit_count (int) – Same as the async method.

  • min_hash_bit_count (int) – Same as the async method.

  • flags (int) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

hll_set_union(hll_list, flags=0)[source]

Merge other HyperLogLog sketches into this bin.

Semantics match aerospike_sdk.aio.operations.query.WriteBinBuilder.hll_set_union().

Example::

session.update(key).bin(“merged”).hll_set_union([other_hll_blob])

Parameters:
  • hll_list (Sequence[Any]) – Same as the async method.

  • flags (int) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

hll_fold(index_bit_count)[source]

Reduce sketch precision to a lower index bit count.

Example::

session.update(key).bin(“hll”).hll_fold(10)

Parameters:

index_bit_count (int) – Same as aerospike_sdk.aio.operations.query.WriteBinBuilder.hll_fold().

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

hll_refresh_count()[source]

Refresh the cached cardinality estimate stored with the sketch.

Example::

session.update(key).bin(“hll”).hll_refresh_count()

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

hll_get_count()[source]

Read the estimated cardinality in a multi-operation write.

Example::

session.update(key).bin(“hll”).hll_get_count()

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

hll_describe()[source]

Read index and min-hash bit parameters of the stored sketch.

Example::

session.update(key).bin(“hll”).hll_describe()

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

hll_get_union(hll_list)[source]

Read the union sketch without modifying the stored bin.

Example::

session.update(key).bin(“hll”).hll_get_union([peer_blob])

Parameters:

hll_list (Sequence[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

hll_get_union_count(hll_list)[source]

Read the estimated cardinality of the union with other sketches.

Parameters:

hll_list (Sequence[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

hll_get_intersect_count(hll_list)[source]

Read the estimated intersection cardinality with other sketches.

Parameters:

hll_list (Sequence[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

hll_get_similarity(hll_list)[source]

Read Jaccard similarity between this sketch and other sketches.

Parameters:

hll_list (Sequence[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_resize(byte_size, resize_flags=None, policy=None)[source]

Grow or shrink the raw bytes backing this bin.

Semantics match aerospike_sdk.aio.operations.query.WriteBinBuilder.bit_resize().

Example::

session.upsert(key).bin(“flags”).bit_resize(4)

Parameters:
  • byte_size (int) – Same as the async method.

  • resize_flags (Optional[Any]) – Same as the async method.

  • policy (Optional[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_insert(byte_offset, value, policy=None)[source]

Insert bytes at a byte offset in the blob bin.

Example::

session.update(key).bin(“blob”).bit_insert(0, b”x01x02”)

Parameters:
  • byte_offset (int) – Same as the async method.

  • value (Any) – Same as the async method.

  • policy (Optional[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_remove(byte_offset, byte_size, policy=None)[source]

Remove a byte range from the blob bin.

Example::

session.update(key).bin(“blob”).bit_remove(0, 2)

Parameters:
Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_set(bit_offset, bit_size, value, policy=None)[source]

Overwrite a bit range with a new value.

Example::

session.update(key).bin(“blob”).bit_set(0, 8, b”xff”)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • value (Any) – Same as the async method.

  • policy (Optional[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_or(bit_offset, bit_size, value, policy=None)[source]

Bitwise OR a value into a bit range.

Example::

session.update(key).bin(“blob”).bit_or(0, 8, b”x0f”)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • value (Any) – Same as the async method.

  • policy (Optional[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_xor(bit_offset, bit_size, value, policy=None)[source]

Bitwise XOR a value into a bit range.

Example::

session.update(key).bin(“blob”).bit_xor(0, 8, b”xff”)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • value (Any) – Same as the async method.

  • policy (Optional[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_and(bit_offset, bit_size, value, policy=None)[source]

Bitwise AND a value into a bit range.

Example::

session.update(key).bin(“blob”).bit_and(0, 8, b”xf0”)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • value (Any) – Same as the async method.

  • policy (Optional[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_not(bit_offset, bit_size, policy=None)[source]

Invert every bit in a range.

Example::

session.update(key).bin(“blob”).bit_not(0, 8)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • policy (Optional[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_lshift(bit_offset, bit_size, shift, policy=None)[source]

Left-shift the bits in a field.

Example::

session.update(key).bin(“blob”).bit_lshift(0, 16, 2)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • shift (int) – Same as the async method.

  • policy (Optional[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_rshift(bit_offset, bit_size, shift, policy=None)[source]

Right-shift the bits in a field.

Example::

session.update(key).bin(“blob”).bit_rshift(0, 16, 2)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • shift (int) – Same as the async method.

  • policy (Optional[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_add(bit_offset, bit_size, value, signed, action, policy=None)[source]

Add to an integer bit field (see aerospike_sdk.aio.operations.query.WriteBinBuilder.bit_add()).

Example::

session.update(key).bin(“blob”).bit_add(0, 16, 1, False, BitwiseOverflowActions.WRAP)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • value (int) – Same as the async method.

  • signed (bool) – Same as the async method.

  • action (Any) – Same as the async method.

  • policy (Optional[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_subtract(bit_offset, bit_size, value, signed, action, policy=None)[source]

Subtract from an integer bit field (see aerospike_sdk.aio.operations.query.WriteBinBuilder.bit_subtract()).

Example::

session.update(key).bin(“blob”).bit_subtract(0, 16, 1, False, BitwiseOverflowActions.SATURATE)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • value (int) – Same as the async method.

  • signed (bool) – Same as the async method.

  • action (Any) – Same as the async method.

  • policy (Optional[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_set_int(bit_offset, bit_size, value, policy=None)[source]

Write an integer value into a bit field.

Example::

session.update(key).bin(“blob”).bit_set_int(0, 16, 42)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • value (int) – Same as the async method.

  • policy (Optional[Any]) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_get(bit_offset, bit_size)[source]

Read a bit range as bytes in a write operate.

Example::

session.update(key).bin(“blob”).bit_get(0, 8)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_count(bit_offset, bit_size)[source]

Count bits set to 1 in a range.

Example::

session.update(key).bin(“blob”).bit_count(0, 8)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_lscan(bit_offset, bit_size, value)[source]

Return the leftmost bit index matching a value in a range.

Example::

session.update(key).bin(“blob”).bit_lscan(0, 8, True)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • value (bool) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_rscan(bit_offset, bit_size, value)[source]

Return the rightmost bit index matching a value in a range.

Example::

session.update(key).bin(“blob”).bit_rscan(0, 8, False)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • value (bool) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

bit_get_int(bit_offset, bit_size, signed)[source]

Decode an integer from a bit field.

Example::

session.update(key).bin(“blob”).bit_get_int(0, 16, False)

Parameters:
  • bit_offset (int) – Same as the async method.

  • bit_size (int) – Same as the async method.

  • signed (bool) – Same as the async method.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder for chaining.

on_map_index(index)[source]

Navigate to a map element by index.

Parameters:

index (int) – Map index to target.

Return type:

CdtWriteBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteBuilder for writing the targeted element.

on_map_key(key, *, create_type=None)[source]

Navigate to a map element by key.

Parameters:
  • key (Any) – Map key to target.

  • create_type (Optional[MapOrder]) – If set, use a create-on-missing context for this key with the given map key order.

Return type:

CdtWriteBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteBuilder for writing the targeted element.

on_map_rank(rank)[source]

Navigate to a map element by rank (0 = lowest value).

Parameters:

rank (int) – Rank position (0 = lowest value).

Return type:

CdtWriteBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteBuilder for writing the targeted element.

on_map_value(value)[source]

Navigate to map elements matching a value.

Parameters:

value (Any) – Value to match.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_map_index_range(index, count=None)[source]

Navigate to map elements by index range.

Parameters:
  • index (int) – Start index.

  • count (Optional[int]) – Maximum entries to select; None for all remaining.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_map_key_range(start, end)[source]

Navigate to map elements by key range [start, end).

Parameters:
  • start (Any) – Inclusive range start.

  • end (Any) – Exclusive range end.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_map_rank_range(rank, count=None)[source]

Navigate to map elements by rank range.

Parameters:
  • rank (int) – Start rank (0 = lowest value).

  • count (Optional[int]) – Maximum entries to select; None for all remaining.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_map_value_range(start, end)[source]

Navigate to map elements by value range [start, end).

Parameters:
  • start (Any) – Inclusive range start.

  • end (Any) – Exclusive range end.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_map_key_relative_index_range(key, index, count=None)[source]

Navigate to map entries by index range relative to an anchor key.

Parameters:
  • key (Any) – Anchor key.

  • index (int) – Relative index offset from the anchor.

  • count (Optional[int]) – Maximum entries; None for all remaining.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_map_value_relative_rank_range(value, rank, count=None)[source]

Navigate to map entries by value rank range relative to an anchor value.

Parameters:
  • value (Any) – Anchor value.

  • rank (int) – Relative rank offset from the anchor.

  • count (Optional[int]) – Maximum entries; None for all remaining.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_map_key_list(keys)[source]

Navigate to map elements matching a list of keys.

Parameters:

keys (List[Any]) – Map keys to match.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_map_value_list(values)[source]

Navigate to map elements matching a list of values.

Parameters:

values (List[Any]) – Values to match.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_list_index(index, *, order=None, pad=False)[source]

Navigate to a list element by index.

Parameters:
  • index (int) – List index (0-based, negative counts from end).

  • order (Optional[ListOrderType]) – If set (or if pad is True), use create-on-missing list context with this order; when only pad is True, defaults to UNORDERED.

  • pad (bool) – When using create-on-missing context, allow sparse indexes.

Return type:

CdtWriteBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteBuilder for writing the targeted element.

on_list_rank(rank)[source]

Navigate to a list element by rank (0 = lowest value).

Parameters:

rank (int) – Rank position (0 = lowest value).

Return type:

CdtWriteBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteBuilder for writing the targeted element.

on_list_value(value)[source]

Navigate to list elements matching a value.

Parameters:

value (Any) – Value to match.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_list_index_range(index, count=None)[source]

Navigate to list elements by index range.

Parameters:
  • index (int) – Start index.

  • count (Optional[int]) – Maximum entries; None for all remaining.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_list_rank_range(rank, count=None)[source]

Navigate to list elements by rank range.

Parameters:
  • rank (int) – Start rank (0 = lowest value).

  • count (Optional[int]) – Maximum entries; None for all remaining.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_list_value_range(start, end)[source]

Navigate to list elements by value range [start, end).

Parameters:
  • start (Any) – Inclusive range start.

  • end (Any) – Exclusive range end.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_list_value_relative_rank_range(value, rank, count=None)[source]

Navigate to list elements by value rank range relative to an anchor value.

Parameters:
  • value (Any) – Anchor value.

  • rank (int) – Relative rank offset from the anchor.

  • count (Optional[int]) – Maximum entries; None for all remaining.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

on_list_value_list(values)[source]

Navigate to list elements matching a list of values.

Parameters:

values (List[Any]) – Values to match.

Return type:

CdtWriteInvertableBuilder[SyncWriteSegmentBuilder]

Returns:

CdtWriteInvertableBuilder for writing the targeted element(s).

select_from(expression, *, ignore_eval_failure=False)[source]

Read a computed value into this bin using an AEL expression.

Parameters:
  • expression (Union[str, FilterExpression]) – AEL string or FilterExpression.

  • ignore_eval_failure (bool) – If True, suppress evaluation errors.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

insert_from(expression, *, ignore_op_failure=False, ignore_eval_failure=False, delete_if_null=False)[source]

Write expression result only if bin does not already exist.

Parameters:
  • expression (Union[str, FilterExpression]) – AEL string or FilterExpression.

  • ignore_op_failure (bool) – If True, suppress operation failures.

  • ignore_eval_failure (bool) – If True, suppress evaluation errors.

  • delete_if_null (bool) – If True, delete the bin when the expression evaluates to null.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

update_from(expression, *, ignore_op_failure=False, ignore_eval_failure=False, delete_if_null=False)[source]

Write expression result only if bin already exists.

Parameters:
  • expression (Union[str, FilterExpression]) – AEL string or FilterExpression.

  • ignore_op_failure (bool) – If True, suppress operation failures.

  • ignore_eval_failure (bool) – If True, suppress evaluation errors.

  • delete_if_null (bool) – If True, delete the bin when the expression evaluates to null.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

upsert_from(expression, *, ignore_op_failure=False, ignore_eval_failure=False, delete_if_null=False)[source]

Write expression result, creating or overwriting the bin.

Parameters:
  • expression (Union[str, FilterExpression]) – AEL string or FilterExpression.

  • ignore_op_failure (bool) – If True, suppress operation failures.

  • ignore_eval_failure (bool) – If True, suppress evaluation errors.

  • delete_if_null (bool) – If True, delete the bin when the expression evaluates to null.

Return type:

SyncWriteSegmentBuilder

Returns:

The parent SyncWriteSegmentBuilder.

bin(bin_name)[source]

Start the next bin operation.

Parameters:

bin_name (str) – Name of the next bin.

Return type:

SyncWriteBinBuilder

Returns:

SyncWriteBinBuilder for the named bin.

query(arg1, *more_keys)[source]

Shortcut: finalize write segment and start a read segment.

Parameters:
  • arg1 (Union[Key, List[Key]]) – Key or list of keys.

  • more_keys (Key) – Additional keys.

Return type:

SyncQueryBuilder

Returns:

SyncQueryBuilder for read operations.

execute(on_error=None)[source]

Shortcut: execute all accumulated operations.

Parameters:

on_error (Union[ErrorStrategy, Callable[[Key, int, AerospikeError], None], None]) – Error handling strategy.

Return type:

SyncRecordStream

Returns:

SyncRecordStream with operation results.