dau_driver.stream_codec

Attributes

_ALIGNMENT_BYTES

_SCALAR_RESULT_STRUCTS

_STRUCT_CODES

_ARROW_TYPE_FACTORIES

Classes

DecodedStreamColumn

DecodedStreamResult

RecordBatchColumn

One fixed-width, null-free input column for record-batch encoding.

DecodedRecordBatch

StreamEncoder

StreamDecoder

Functions

_arrow_to_logical_type(arrow_type) → dau_core.stream.LogicalType

_logical_to_arrow_type(logical_type)

_validate_header(header, encoded_length) → None

_validate_column(header, column, encoded_length) → None

_validate_operations(header, operations) → None

_validate_payload_window(payload_offset, ...) → None

_normalize_supported_type(logical_type) → dau_core.stream.LogicalType

_normalize_operation_descriptor(operation, *[, ...]) → dau_core.stream.OperationDescriptor

_unpack_column(data) → dau_core.stream.ColumnDescriptor

_unpack_operation(data) → dau_core.stream.OperationDescriptor

_align_up(value, alignment) → int

Module Contents

dau_driver.stream_codec._ALIGNMENT_BYTES = 64
dau_driver.stream_codec._SCALAR_RESULT_STRUCTS
dau_driver.stream_codec._STRUCT_CODES
dau_driver.stream_codec._arrow_to_logical_type(arrow_type) → dau_core.stream.LogicalType[source]
dau_driver.stream_codec._logical_to_arrow_type(logical_type: dau_core.stream.LogicalType)[source]
dau_driver.stream_codec._ARROW_TYPE_FACTORIES
class dau_driver.stream_codec.DecodedStreamColumn[source]
header: dau_core.stream.BatchHeader
column: dau_core.stream.ColumnDescriptor
payload: bytes
operations: tuple[dau_core.stream.OperationDescriptor, ...] = ()
class dau_driver.stream_codec.DecodedStreamResult[source]
header: dau_core.stream.BatchHeader
column: dau_core.stream.ColumnDescriptor
payload: bytes
value: int | float
class dau_driver.stream_codec.RecordBatchColumn[source]

One fixed-width, null-free input column for record-batch encoding.

field_id: int
logical_type: dau_core.stream.LogicalType
payload: bytes
class dau_driver.stream_codec.DecodedRecordBatch[source]
header: dau_core.stream.BatchHeader
columns: tuple[dau_core.stream.ColumnDescriptor, ...]
payloads: tuple[bytes, ...]
operations: tuple[dau_core.stream.OperationDescriptor, ...] = ()
column_payload(field_id: int) → bytes[source]
class dau_driver.stream_codec.StreamEncoder[source]
static encode_column(logical_type: dau_core.stream.LogicalType, payload: bytes, *, row_count: int, field_id: int = 0, schema_hash: int = 0, batch_id: int = 0, operations: collections.abc.Iterable[dau_core.stream.OperationDescriptor] = ()) → bytes[source]
static encode_record_batch(columns: collections.abc.Sequence[RecordBatchColumn], *, row_count: int, schema_hash: int = 0, batch_id: int = 0, operations: collections.abc.Iterable[dau_core.stream.OperationDescriptor] = (), limits: dau_core.stream.RecordBatchLimits = DEFAULT_RECORD_BATCH_LIMITS) → bytes[source]

Encode N fixed-width, null-free columns as one multi-column batch.

static encode_arrow_batch(batch, *, schema_hash: int = 0, batch_id: int = 0, operations: collections.abc.Iterable[dau_core.stream.OperationDescriptor] = (), limits: dau_core.stream.RecordBatchLimits = DEFAULT_RECORD_BATCH_LIMITS) → bytes[source]

Encode a PyArrow RecordBatch/Table of fixed-width, null-free columns.

class dau_driver.stream_codec.StreamDecoder[source]
static decode_column(data: bytes) → DecodedStreamColumn[source]
static decode_record_batch(data: bytes, *, limits: dau_core.stream.RecordBatchLimits = DEFAULT_RECORD_BATCH_LIMITS) → DecodedRecordBatch[source]

Decode a multi-column record batch (the N-column counterpart of decode_column).

static decode_record_batch_to_arrow(data: bytes, *, names: collections.abc.Sequence[str] | None = None, limits: dau_core.stream.RecordBatchLimits = DEFAULT_RECORD_BATCH_LIMITS)[source]

Decode and rematerialize as a PyArrow RecordBatch.

static decode_scalar_result(data: bytes) → DecodedStreamResult[source]
dau_driver.stream_codec._validate_header(header: dau_core.stream.BatchHeader, encoded_length: int) → None[source]
dau_driver.stream_codec._validate_column(header: dau_core.stream.BatchHeader, column: dau_core.stream.ColumnDescriptor, encoded_length: int) → None[source]
dau_driver.stream_codec._validate_operations(header: dau_core.stream.BatchHeader, operations: tuple[dau_core.stream.OperationDescriptor, ...]) → None[source]
dau_driver.stream_codec._validate_payload_window(payload_offset: int, payload_length: int, encoded_length: int) → None[source]
dau_driver.stream_codec._normalize_supported_type(logical_type: dau_core.stream.LogicalType) → dau_core.stream.LogicalType[source]
dau_driver.stream_codec._normalize_operation_descriptor(operation: dau_core.stream.OperationDescriptor, *, column_count: int = 1) → dau_core.stream.OperationDescriptor[source]
dau_driver.stream_codec._unpack_column(data: bytes) → dau_core.stream.ColumnDescriptor[source]
dau_driver.stream_codec._unpack_operation(data: bytes) → dau_core.stream.OperationDescriptor[source]
dau_driver.stream_codec._align_up(value: int, alignment: int) → int[source]