OperationResult¶
- class aerospike_sdk.operation_result.OperationResult[source]¶
Bases:
objectTyped-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. Eachget_*method coerces or rejects the underlying type explicitly so silent miscasts surface asTypeErrorrather than mysterious runtime failures elsewhere.Numeric and boolean accessors return idiomatic defaults (
0,0.0,False) when the wrapped value isNone, 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.- get_int()[source]¶
Return the value as an integer;
0when the value isNone.Booleans are treated as integers per Python semantics (
True→ 1). The returned value is a full Pythonint— arbitrary precision, never truncated to a fixed width.- Return type:
- Returns:
The wrapped integer, or
0when the value isNone.- Raises:
TypeError – When the wrapped value is neither
intnorNone.
Example:
result = record.typed_operation_result(0) visits = result.get_int()
See also
get_float(): Floating-point accessor.value(): Raw access without coercion.
- get_float()[source]¶
Return the value as a float;
0.0when the value isNone.Integers are widened to float for convenience; strings and other types raise. Python floats are double precision, so no narrowing occurs.
- Return type:
- Returns:
The wrapped value as a float, or
0.0when the value isNone.- Raises:
TypeError – When the wrapped value is neither numeric nor
None.
Example:
result = record.typed_operation_result(0) balance = result.get_float()
- get_bool()[source]¶
Return the value as a boolean;
Falsewhen the value isNone.Accepts both native booleans and integers so values written by older clients (which encoded booleans as longs) still decode correctly.
- get_bytes()[source]¶
Return the value as
bytes;Noneis propagated.Bytearrays are accepted and converted; other types raise.