RecordResult¶
- class aerospike_sdk.record_result.RecordResult[source]¶
Bases:
objectOne row from a batch, query stream, or single-key SDK call.
Inspect
is_okandresult_codefor outcome; useor_raise()orrecord_or_raise()when failures should throw. Foreground UDF success values appear inudf_resultwhen returned by the server.- key¶
Target
Keyfor this row.
- record¶
Recordpayload, orNoneif not returned (errors, not found, or UDF error rows).
- result_code¶
Server
ResultCode.
- in_doubt¶
Truewhen a write may have completed despite an error.
- index¶
Batch position, or
0/-1depending on origin.
- exception¶
Embedded
AerospikeErrorwhen 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¶
- result_code: ResultCode¶
- exception: AerospikeError | None¶
- property is_ok: bool¶
Whether
result_codeisResultCode.OK.- Returns:
Trueon success;Falsefor 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
selfif successful, else raise fromexceptionor result code.- Return type:
- Returns:
This instance when
is_okis true.- Raises:
AerospikeError – If
exceptionis set (embedded client error).AerospikeError – Otherwise, from
result_codevia_result_code_to_exception()(usually a specific subclass; unmapped codes use the base type).
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-
NoneRecord.
:raises Same as
or_raise`(),plus ``ValueError`if the result is OK: :raises butrecordisNone(unexpected empty payload).:Example
rec = (await stream.first_or_raise()).record_or_raise()
- as_bool()[source]¶
Interpret the row as an existence check (for example after
Session.exists()).- Return type:
- Returns:
Trueif the key exists (OK result).Falseif 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)¶