RecordResult

class aerospike_sdk.record_result.RecordResult[source]

Bases: object

One row from a batch, query stream, or single-key SDK call.

Inspect is_ok and result_code for outcome; use or_raise() or record_or_raise() when failures should throw. Foreground UDF success values appear in udf_result when returned by the server.

key

Target Key for this row.

record

Record payload, or None if not returned (errors, not found, or UDF error rows).

result_code

Server ResultCode.

in_doubt

True when a write may have completed despite an error.

index

Batch position, or 0 / -1 depending on origin.

exception

Embedded AerospikeError when the client placed an error in-stream instead of raising.

udf_result

Lua return value for successful foreground UDF calls.

Example

Inspect a row from a stream:

row = await stream.first()
if row and row.is_ok:
    bins = row.record.bins if row.record else {}
elif row:
    row.or_raise()

See also

RecordStream: Async iteration of results.

key: Key
record: Record | None
result_code: ResultCode
in_doubt: bool
index: int
exception: AerospikeError | None
udf_result: Any | None
property is_ok: bool

Whether result_code is ResultCode.OK.

Returns:

True on success; False for any other result code.

Example:

row = await stream.first()
if row is not None and row.is_ok and row.record:
    bins = row.record.bins
or_raise()[source]

Return self if successful, else raise from exception or result code.

Return type:

RecordResult

Returns:

This instance when is_ok is true.

Raises:

Example:

row = await stream.first()
if row is not None:
    row.or_raise()
record_or_raise()[source]

Return record, raising if the result is not OK.

Return type:

Record

Returns:

The non-None Record.

:raises Same as or_raise`(), plus ``ValueError` if the result is OK: :raises but record is None (unexpected empty payload).:

Example

rec = (await stream.first_or_raise()).record_or_raise()

get_hll_config(bin_name)[source]

Return the HLL bin’s HllConfig from a hll_describe() result.

Wraps the two-element [index_bit_count, min_hash_bit_count] list that hll_describe() writes back into the bin and returns it as an HllConfig. Returns None if the bin is absent from the record (or the record itself is None).

Parameters:

bin_name (str) – Name of the bin holding a hll_describe() result.

Return type:

HllConfig | None

Returns:

An HllConfig, or None if the bin is absent.

Raises:

TypeError – If the bin value is not a 2-element list of ints.

Example:

result = await (
    session.update(key).bin("h").hll_describe().execute()
).first_or_raise()
cfg = result.get_hll_config("h")
assert cfg.index_bit_count == 14
as_bool()[source]

Interpret the row as an existence check (for example after Session.exists()).

Return type:

bool

Returns:

True if the key exists (OK result). False if the result is key-not-found.

Raises:

AerospikeError – For any other non-OK code (via or_raise()).

Example

found = (await exists_stream.first_or_raise()).as_bool()

__init__(key, record, result_code, in_doubt=False, index=-1, exception=None, udf_result=None)