RecordStream (sync)¶
- class aerospike_sdk.sync.record_stream.RecordStream[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.- pop()[source]¶
Advance one row and return it (or
None), keeping the stream open.Non-closing counterpart of
first(). Per-record failures come back as data on theRecordResult(is_ok=False); cluster-level errors raise from iteration.- Return type:
- pop_or_raise()[source]¶
Advance one row and require success, keeping the stream open.
Non-closing counterpart of
first_or_raise().- Raises:
RecordNotFoundError – If the stream is exhausted (empty).
AerospikeError – If the row is not OK (from
RecordResult.or_raise()).
- Return type:
- first()[source]¶
Return the first row (or
Noneif empty), then close the stream.Terminal convenience: takes one row via
pop(), thenclose()s to release the underlying producer. Usepop()to keep iterating.See also
first(): Same terminal on the builder.- Return type:
- first_or_raise()[source]¶
Return the first row, require success, then close the stream.
Terminal counterpart of
pop_or_raise().See also
first_or_raise(): Same terminal on the builder.- Return type:
- close()[source]¶
Stop iteration and release the underlying producer.
Marks the stream closed so further iteration raises
StopIteration, and — for lazily-fed streams (a batchstreamor a query recordset) — forwards to the underlying producer’sclose()so its receiver / server-side scan is released now rather than at garbage-collection time. In-flight batch requests still complete in the background. Idempotent; always call it when abandoning a lazy stream before it is fully drained.- Return type:
- has_more_chunks()[source]¶
Return whether more server-side chunks remain.
First call always returns
Trueso the caller enters the loop for the already-loaded first chunk. Subsequent calls inspect the cursor; new chunks are fetched transparently viareexecute.- Raises:
AerospikeError – The cursor read or the next chunk’s query failed.
- Return type: