SyncRecordStream¶
- class aerospike_sdk.sync.record_stream.SyncRecordStream[source]¶
Bases:
objectSynchronous iterator of
RecordResult.Produced by sync builder terminals (
execute()). Iterate with a regularforloop or use the helpers below (first,collect,failures, …). Single-pass — most underlying sources do not support resetting.Example:
for row in session.query(key).bins(["name"]).execute(): if row.is_ok and row.record: print(row.record.bins)
See also
aerospike_sdk.record_stream.RecordStream: async counterpart.- classmethod from_batch_records(batch_records)[source]¶
Wrap a list of PAC
BatchRecordobjects.- Return type:
- classmethod from_pac_batch_stream(pac_stream, on_error=None)[source]¶
Lazy-feed adapter over a PAC
BatchRecordStream(sync iter).See
aerospike_sdk.record_stream.RecordStream.from_pac_batch_stream()for the contract. This sync variant pulls(idx, BatchRecord)tuples via PAC’s blocking__iter__/__next__and maps each to aRecordResultwithindex=idx(NOT enumeration — completion order can differ from input order).- Parameters:
pac_stream (
Any) – PACBatchRecordStream(sync iter) to drain.on_error (
Optional[Callable[[Key,int,AerospikeError],None]]) – Optional(key, index, exception) -> Nonecallback. When set, per-key failures are dispatched to the handler and excluded from the returned stream; cluster-level errors still raise from__next__.
- Return type:
- classmethod from_pac_recordset(recordset)[source]¶
Wrap a PAC
Recordset(sync__iter__/__next__).Each yielded
Recordbecomes an OKRecordResultwithindex=-1(queries have no positional index).- Return type:
- classmethod from_chunked_pac_recordset(recordset, reexecute, limit=0)[source]¶
Wrap a PAC
Recordsetfor chunked iteration.reexecuteis a sync callable that takes the currentPartitionFilterand returns the nextRecordset(orNoneto stop). Usehas_more_chunks()to advance.- Return type:
- classmethod from_single(key, record)[source]¶
Wrap a single-key result.
Sets
result_code = OKwhenrecord is not None; otherwiseKEY_NOT_FOUND_ERROR.- Return type:
- classmethod from_error(key, result_code, in_doubt=False, exception=None)[source]¶
Wrap a single-key error as a one-element stream.
- Return type:
- first_or_raise()[source]¶
Return the first row, or raise if the stream is empty / not OK.
- Return type: