OperationResult

class aerospike_sdk.operation_result.OperationResult[source]

Bases: object

Typed-accessor wrapper around a single value from a write or operate command.

The wrapped value can be any type the server returns: integer, float, string, bytes, list, map, GeoJSON, HLL, boolean, or None. Each get_* method coerces or rejects the underlying type explicitly so silent miscasts surface as TypeError rather than mysterious runtime failures elsewhere.

Numeric and boolean accessors return idiomatic defaults (0, 0.0, False) when the wrapped value is None, matching how other SDKs model an absent result for a write-then-read sequence on a bin that did not exist.

Example:

result = OperationResult(42)
result.get_int()       # 42
result.get_string()    # raises TypeError — value is int, not str
result.value           # 42 (raw)

See also

OperationResult.value(): Raw access without coercion.

__init__(value)[source]
property value: Any

The raw underlying value, with no coercion.

get_long()[source]

Return the value as an integer; 0 when the value is None.

Booleans are treated as integers per Python semantics (True → 1).

Raises:

TypeError – When the wrapped value is neither int nor None.

Return type:

int

get_int()[source]

Alias for get_long() — Python int is unbounded so the int / long distinction is purely for naming parity.

Return type:

int

get_double()[source]

Return the value as a float; 0.0 when the value is None.

Integers are widened to float for convenience; strings and other types raise.

Raises:

TypeError – When the wrapped value is neither numeric nor None.

Return type:

float

get_float()[source]

Alias for get_double().

Return type:

float

get_bool()[source]

Return the value as a boolean; False when the value is None.

Accepts both native booleans and integers so values written by older clients (which encoded booleans as longs) still decode correctly.

Raises:

TypeError – When the wrapped value is not a bool, int, or None.

Return type:

bool

get_string()[source]

Return the value as str; None is propagated.

Raises:

TypeError – When the wrapped value is non-None and not a string.

Return type:

str | None

get_bytes()[source]

Return the value as bytes; None is propagated.

Bytearrays are accepted and converted; other types raise.

Return type:

bytes | None

get_list()[source]

Return the value as list; None is propagated.

Raises:

TypeError – When the wrapped value is non-None and not a list.

Return type:

list[Any] | None

get_map()[source]

Return the value as dict; None is propagated.

Raises:

TypeError – When the wrapped value is non-None and not a dict.

Return type:

dict[Any, Any] | None