Stream HTTP data to Apache Arrow format for efficient processing and analytics.
Project description
http-to-arrow
http-to-arrow provides Arrow-backed containers for streaming HTTP and ETL-style
ingestion workflows.
The package uses a standard source layout so code lives under
src/http_to_arrow/src/http_to_arrow/ rather than the project root.
Package-specific tests currently live under tests/http_to_arrow/ at the
monorepo root.
Included exports
ArrowRecordContainerArrowIPCStreamIPCStreamSinkUnknownFieldPolicyMissingFieldPolicyCoercionPolicy
Explicit schema
import pyarrow as pa
from http_to_arrow import ArrowRecordContainer
container = ArrowRecordContainer(
schema=pa.schema([
pa.field("id", pa.int64()),
pa.field("name", pa.string()),
])
)
container.append({"id": 1, "name": "alpha"})
Inferred schema
from http_to_arrow import ArrowRecordContainer
container = ArrowRecordContainer(schema=None)
container.append({"ID": 1})
container.append({"id": 2, "name": "beta"})
table = container.to_table()
assert table.to_pydict() == {
"ID": [1, 2],
"name": [None, "beta"],
}
Notes
schema=Noneenables inferred mode.- Inferred mode widens as new fields appear and backfills older rows with nulls.
- Conflicting inferred field types widen when possible and otherwise fall back to
string. to_table()raises when inferred mode has neither an explicit schema nor any appended records.
Materialization outputs
Use to_table() to materialize pending rows and batches as a cached PyArrow
table. to_arrow() is a compatibility alias for the same table path.
Use to_polars_frame() to materialize the same data as a Polars DataFrame.
to_polars() is a compatibility alias.
Batch access for streaming
Long-running streaming consumers can release completed batches without building one large table:
drain_batches()returns completed pendingRecordBatchobjects and clears them from the container.iter_batches()yields completed batches in FIFO order and releases each one as it is yielded.flush_partial()emits a trailing short batch from the in-flight accumulator and removes it from pending state so it is not materialized again later.
These helpers underpin ArrowIPCStream, which serializes completed batches to
Arrow IPC bytes while keeping peak memory close to the active batch.
Memory tuning
For high-volume ingestion paths (for example streaming large HTTP responses into a single materialized Arrow table) the container exposes a few opt-in knobs to bound peak memory. All defaults preserve the historical behavior.
dictionary_encode=True(explicit schemas only): low-cardinalitystringandlarge_stringcolumns are dictionary-encoded at flush time, producing dictionary-typed Arrow columns. Once a column is encoded, subsequent batches stay encoded sopa.Table.from_batchesaccepts them.dictionary_cardinality_threshold(default0.5): a column is only encoded whenlen(dictionary) / len(array) <= thresholdon the first qualifying batch. Must be in[0.0, 1.0].compact_on_materialize=True: runspa.Table.combine_chunks()after materializing pending batches into_table()orincremental_flush(), reducing the chunk fragmentation that builds up across many flushes.eager_clear_accumulator=True: each accumulator column list is released as soon as its Arrow array is built duringflush(). This is opt-in because it changes failure semantics: if a later column raises mid-flush the cleared earlier columns cannot be re-converted from the same in-flight rows.- For memory-constrained runtimes, lowering
batch_size(default128_000) reduces the size of the Python accumulator held between flushes at the cost of more frequent batch construction.
Streaming IPC
For memory-constrained runtimes (for example a 2 GiB Azure Function exporting
millions of rows) you can stream completed batches out as Arrow IPC stream bytes
instead of materializing one large table. ArrowIPCStream runs an async
producer (such as HTTP pagination) and a consumer that serializes each completed
RecordBatch to Arrow IPC bytes and releases it immediately, so peak memory
stays close to a single batch. A bounded asyncio.Queue applies backpressure so
the producer never outruns serialization.
Streaming requires an explicit schema because the IPC stream header is written
before any rows arrive. Inferred-schema mode and dictionary_encode=True are
rejected for streaming.
import pyarrow as pa
from http_to_arrow import ArrowIPCStream
schema = pa.schema([pa.field("id", pa.int64()), pa.field("name", pa.string())])
async def stream_rows():
stream = ArrowIPCStream(schema=schema, batch_size=128_000, compression="zstd")
async def produce() -> None:
async for page in fetch_pages(): # your async paginator
await stream.extend(page)
async for chunk in stream.ipc_chunks(producer=produce):
yield chunk # forward each chunk to the streaming HTTP response
Consume the stream on the client with pyarrow.ipc.open_stream:
import pyarrow as pa
reader = pa.ipc.open_stream(pa.BufferReader(response_bytes))
table = reader.read_all()
For advanced composition, IPCStreamSink exposes the per-batch IPC
serialization directly without the async orchestration.
The helper modules under http_to_arrow are private implementation details,
including underscored modules and shared base classes. The public surface is
ArrowRecordContainer, ArrowIPCStream, IPCStreamSink, and the three policy
aliases exported from http_to_arrow.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file http_to_arrow-0.2.0.tar.gz.
File metadata
- Download URL: http_to_arrow-0.2.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
423a72cbc02e0035f096d85cf5f360339ef936c86bba0b7d97034c1b2549ba06
|
|
| MD5 |
02db98a0e181897343283ad47bee6c94
|
|
| BLAKE2b-256 |
647bc57f01e4ec6d242fcdbeb8c74d944f44066e21362933caf03c6a2ca3ae93
|
Provenance
The following attestation bundles were made for http_to_arrow-0.2.0.tar.gz:
Publisher:
publish-http-to-arrow.yml on ProxayFox/proxay-pylibs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
http_to_arrow-0.2.0.tar.gz -
Subject digest:
423a72cbc02e0035f096d85cf5f360339ef936c86bba0b7d97034c1b2549ba06 - Sigstore transparency entry: 1730287010
- Sigstore integration time:
-
Permalink:
ProxayFox/proxay-pylibs@1344be003019ce847e04cb237be74692017bbd77 -
Branch / Tag:
refs/tags/http-to-arrow-v0.2.0 - Owner: https://github.com/ProxayFox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-http-to-arrow.yml@1344be003019ce847e04cb237be74692017bbd77 -
Trigger Event:
release
-
Statement type:
File details
Details for the file http_to_arrow-0.2.0-py3-none-any.whl.
File metadata
- Download URL: http_to_arrow-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
923dbdc903f1828135b8bb1466674f9158bc99bde502c8485c0873279e3d4e77
|
|
| MD5 |
bac8bb25bd6911b45873e279dfe32839
|
|
| BLAKE2b-256 |
3732cb11988469a88892822ed32e9d8c78d8d6c286542b1456b7efc5949a07a0
|
Provenance
The following attestation bundles were made for http_to_arrow-0.2.0-py3-none-any.whl:
Publisher:
publish-http-to-arrow.yml on ProxayFox/proxay-pylibs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
http_to_arrow-0.2.0-py3-none-any.whl -
Subject digest:
923dbdc903f1828135b8bb1466674f9158bc99bde502c8485c0873279e3d4e77 - Sigstore transparency entry: 1730287146
- Sigstore integration time:
-
Permalink:
ProxayFox/proxay-pylibs@1344be003019ce847e04cb237be74692017bbd77 -
Branch / Tag:
refs/tags/http-to-arrow-v0.2.0 - Owner: https://github.com/ProxayFox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-http-to-arrow.yml@1344be003019ce847e04cb237be74692017bbd77 -
Trigger Event:
release
-
Statement type: