RecordStream (sync)

class aerospike_sdk.sync.record_stream.RecordStream[source]

Bases: object

Synchronous iterator of RecordResult.

Produced by sync builder terminals (execute()). Iterate with a regular for loop 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.

__init__(source)[source]
classmethod chain(streams)[source]

Yield all results from each stream in order.

Return type:

RecordStream

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 the RecordResult (is_ok=False); cluster-level errors raise from iteration.

Return type:

Optional[RecordResult]

pop_or_raise()[source]

Advance one row and require success, keeping the stream open.

Non-closing counterpart of first_or_raise().

Raises:
Return type:

RecordResult

first()[source]

Return the first row (or None if empty), then close the stream.

Terminal convenience: takes one row via pop(), then close()s to release the underlying producer. Use pop() to keep iterating.

See also

first(): Same terminal on the builder.

Return type:

Optional[RecordResult]

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:

RecordResult

first_udf_result()[source]

Scan forward for the first non-None udf_result.

Return type:

Any | None

collect()[source]

Drain the stream into a list.

Return type:

list[RecordResult]

failures()[source]

Drain the stream, returning only rows whose is_ok is false.

Return type:

list[RecordResult]

close()[source]

Stop iteration and release the underlying producer.

Marks the stream closed so further iteration raises StopIteration, and — for lazily-fed streams (a batch stream or a query recordset) — forwards to the underlying producer’s close() 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:

None

has_more_chunks()[source]

Return whether more server-side chunks remain.

First call always returns True so the caller enters the loop for the already-loaded first chunk. Subsequent calls inspect the cursor; new chunks are fetched transparently via reexecute.

Raises:

AerospikeError – The cursor read or the next chunk’s query failed.

Return type:

bool