Sync UDF Builders

Synchronous foreground UDF builders (blocking terminals).

Chain state and chaining methods live on the shared, runtime-agnostic bases in aerospike_sdk.udf_shared; this module adds the blocking execute() terminal. The wrapped query builder is the sync QueryBuilder (constructed by execute_udf()), so verb transitions inherited from the base already return sync segment types.

class aerospike_sdk.sync.operations.udf.UdfBuilder[source]

Bases: _UdfBuilderBase[QueryBuilder]

Chain UDF arguments, optional filter, and execution (sync).

See also

UdfBuilder: Async equivalent.

Examples

session.execute_udf(key).function(“pkg”, “fn”).passing(1, 2).execute() session.execute_udf(key).function(“pkg”, “fn”).query(key).where(“true”).execute()

query(arg1, *more_keys)[source]

Close the UDF operation and begin a sync read query segment.

Return type:

QueryBuilder

execute(on_error=None)[source]

Run the UDF and return a RecordStream.

Parameters:

on_error (Union[ErrorStrategy, Callable[[Key, int, AerospikeError], None], None]) – Same semantics as query/write execute().

See also

execute()

Return type:

RecordStream

__init__(qb)
default_expire_record_after(duration)

Default TTL from a datetime.timedelta.

Return type:

Self

default_expire_record_after_seconds(seconds)

Default TTL, in seconds, for chained operations without their own.

Return type:

Self

default_expire_record_at(when)

Default TTL expressed as an absolute expiry instant.

Return type:

Self

default_expiry_from_server_default()

Default chained operations to the namespace’s configured TTL.

Return type:

Self

default_never_expire()

Default chained operations to never expire.

Return type:

Self

default_where(expression, *params)

Filter applied to chained operations that do not call where.

Return type:

Self

default_with_durable_delete()

Prefer durable deletes when resolving policy defaults.

Return type:

Self

default_with_no_change_in_expiration()

Default chained operations to leave the existing TTL untouched.

Return type:

Self

default_without_durable_delete()

Prefer non-durable deletes when resolving policy defaults.

Return type:

Self

delete(arg1, *more_keys)

Finalize the UDF operation and start a delete segment.

Return type:

WriteSegmentBuilder

Returns:

A write-segment builder for chaining.

execute_udf(*keys)

Finalize this UDF operation and start another on keys.

Parameters:

*keys (Key) – One or more keys for the next UDF segment.

Return type:

UdfFunctionBuilder

Returns:

A new UdfFunctionBuilder to call function again.

Raises:

ValueError – If no keys are provided.

exists(arg1, *more_keys)

Finalize the UDF operation and start an exists-check segment.

Return type:

WriteSegmentBuilder

Returns:

A write-segment builder for chaining.

expire_record_after(duration)

Set the TTL using a datetime.timedelta.

Equivalent to expire_record_after_seconds() with seconds derived from duration — convenient when the caller already has a timedelta (timedelta(days=30), etc.). A timedelta resolving to -1, -2, or 0 seconds selects the corresponding TTL sentinel.

Parameters:

duration (timedelta) – Time-to-live.

Return type:

Self

Returns:

self for method chaining.

expire_record_after_seconds(seconds)

Set the TTL on the current operation.

Parameters:

seconds (int) – Time-to-live in seconds. A positive value sets an explicit TTL; the sentinels -1, -2, and 0 select never-expire, no-change, and namespace-default respectively (see never_expire(), with_no_change_in_expiration(), and expiry_from_server_default() for named equivalents). The value is not range-checked here — one the client cannot represent is rejected when the operation is built.

Return type:

Self

Returns:

self for method chaining.

expire_record_at(when)

Set the TTL so the record expires at an absolute point in time.

A naive when is interpreted in local time; pass a timezone-aware datetime for explicit UTC or other zones.

Parameters:

when (datetime) – Future point at which the record should expire.

Return type:

Self

Returns:

self for method chaining.

Raises:

ValueError – If when is not strictly in the future.

expiry_from_server_default()

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

Return type:

Self

fail_on_filtered_out()

Mark filtered-out records with FILTERED_OUT result code.

Return type:

Self

include_missing_keys()

For batch UDF, emit a row per requested key (including not-found).

Return type:

Self

Returns:

This builder for chaining.

See also

QueryBuilder.include_missing_keys(): Same flag for reads.

insert(arg1, *more_keys)

Finalize the UDF operation and start an insert-only write segment.

Return type:

WriteSegmentBuilder

Returns:

A write-segment builder for chaining.

never_expire()

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

Return type:

Self

passing(*args)

Set positional arguments forwarded to the Lua function.

The Aerospike server automatically passes the record as the first argument to the UDF; values provided here follow it.

Parameters:

*args (Any) – Values serialized by the async client (scalars, lists, maps, bytes).

Return type:

Self

Returns:

This builder for chaining.

Example::

builder.passing(“binName”, 42)

replace(arg1, *more_keys)

Finalize the UDF operation and start a replace write segment.

Return type:

WriteSegmentBuilder

Returns:

A write-segment builder for chaining.

replace_if_exists(arg1, *more_keys)

Finalize the UDF operation and start a replace-if-exists segment.

Return type:

WriteSegmentBuilder

Returns:

A write-segment builder for chaining.

touch(arg1, *more_keys)

Finalize the UDF operation and start a touch segment.

Return type:

WriteSegmentBuilder

Returns:

A write-segment builder for chaining.

update(arg1, *more_keys)

Finalize the UDF operation and start an update-only write segment.

Return type:

WriteSegmentBuilder

Returns:

A write-segment builder for chaining.

upsert(arg1, *more_keys)

Finalize the UDF operation and start an upsert write segment.

Return type:

WriteSegmentBuilder

Returns:

A write-segment builder for chaining.

where(expression, *params)

Apply a filter expression so the UDF runs only when the predicate matches.

Overloads:
  • self, expression (str), params (Any) → Self

  • self, expression (FilterExpression) → Self

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

  • *params (Any) – Values for printf placeholders in an AEL template. See QueryBuilder.where() for the interpolation contract.

Returns:

This builder for chaining.

Raises:

ValueError – If where has already been called on this operation.

See also

QueryBuilder.where(): Same AEL for reads.

with_durable_delete()

Force durable delete for this UDF invocation.

Return type:

Self

with_no_change_in_expiration()

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

Return type:

Self

with_txn(txn)

Opt the chain into (or out of) a specific transaction.

Parameters:

txn (Optional[Txn]) – The Txn to participate in, or None to run without a transaction, including an implicit batch-write one.

Return type:

Self

Returns:

This builder for chaining.

without_durable_delete()

Force non-durable delete for this UDF invocation.

Return type:

Self

class aerospike_sdk.sync.operations.udf.UdfFunctionBuilder[source]

Bases: _UdfFunctionBuilderBase[QueryBuilder]

First step after execute_udf: select package and function name.

See also

UdfFunctionBuilder: Async equivalent.

Examples

session.execute_udf(key).function(“pkg”, “fn”)

__init__(qb)
function(package, function_name)

Select the registered module and function to invoke.

Parameters:
  • package (str) – Server-side module name (no .lua suffix).

  • function_name (str) – Lua function symbol exported by the module.

Return type:

UdfBuilder

Returns:

A UdfBuilder for arguments and execution.

Raises:

ValueError – If package or function_name is empty.