Container¶
The http_to_arrow.main module contains the primary ArrowRecordContainer
implementation.
Tip
Most users should import ArrowRecordContainer from http_to_arrow rather
than from http_to_arrow.main.
main
¶
Shared Arrow-backed record containers for ETL-style ingestion flows.
ArrowRecordContainer(schema=None, table=None, batch_size=128000, unknown_field_policy='drop', missing_field_policy='null', coercion_policy='coerce', case_insensitive_keys=True, eager_clear_accumulator=False, dictionary_encode=False, dictionary_cardinality_threshold=0.5, compact_on_materialize=False, batches=None)
dataclass
¶
Bases: BaseArrowRecordContainer, ArrowRecordContainerSettings
Batch incoming records into Arrow tables using an explicit or inferred schema.
Source code in src/http_to_arrow/src/http_to_arrow/main.py
batch_total_rows
property
¶
Total rows across pending batches plus the in-flight accumulator.
total_rows
property
¶
Total rows across the cached table, pending batches, and accumulator.
normalize_record(record)
¶
append(record)
¶
extend(records)
¶
flush()
¶
to_table()
¶
incremental_flush(threshold=0)
¶
Flush accumulated batches into the cached table when above threshold rows.
Unlike to_table() this is designed to be called periodically during
streaming ingestion to bound memory. When the pending batch row count
exceeds threshold, the batches are materialised into the cached table
and the batch list is cleared.
Returns True when batches were actually flushed, False otherwise.
Source code in src/http_to_arrow/src/http_to_arrow/main.py
drain_batches()
¶
Return completed pending batches and remove them from the container.
This releases ownership of every flushed RecordBatch without
touching the in-flight accumulator or the cached table. After draining,
:attr:batch_total_rows reflects only the rows still held in the
accumulator.
Returns an empty list when no batches are pending.
Source code in src/http_to_arrow/src/http_to_arrow/main.py
flush_partial()
¶
Flush the in-flight accumulator and return the resulting batch.
Unlike :meth:flush, this returns the newly created RecordBatch and
removes it from the pending batch list so a later :meth:to_table call
does not materialize it a second time. Returns None when the
accumulator holds no rows.
Source code in src/http_to_arrow/src/http_to_arrow/main.py
iter_batches()
¶
Yield completed batches one at a time, releasing each as it is yielded.
Batches are yielded in FIFO order and removed from the container as they
are produced, so memory is not retained for already-yielded batches. The
in-flight accumulator is left untouched; call :meth:flush_partial
first to emit a trailing short batch.