Expand description
§Arrow-C-FFI Module - Share data to another language and/or run-time*
Implements the Apache Arrow C Data Interface for Minarrow, enabling zero-copy
data exchange across language boundaries.
Compatible with any runtime implementing the Arrow C interface, including Python, C++,
Java, and others.
§Features
- Export: Convert Minarrow arrays into Arrow C
ArrowArrayandArrowSchemapointers. - Import: Construct Minarrow arrays directly from Arrow C pointers.
- Type fidelity: Preserves physical layout, logical type metadata, and temporal units.
- FFI safety: Backing buffers are reference-counted to ensure lifetime validity across the boundary, with explicit release functions for deallocation.
§Usage
- Ensure the array has an associated
Fieldor is wrapped in aFieldArray. - For temporal arrays, set the correct
ArrowTypewith appropriateTimeUnitorIntervalUnit. - Call
export_to_cto obtain Arrow-compatible pointers for FFI transmission. - On the receiving side, reconstruct a Minarrow array with
import_from_c.
§Examples
- Rust -> Arrow:
cargo run --example apache-ffi - Planned: Python, C++, and other language bindings.
§Notes
- Dictionary-encoded (categorical) arrays are supported, including index type mapping.
- UTF-8 and large UTF-8 string arrays preserve offset and value buffer ordering.
- Temporal arrays validate logical type <-> physical storage alignment prior to export.
pyo3normally abstracts pointer handling and lifetime management when integrating with Python; we do not yet use it, but once integrated, instead of manualArcreference count handling and explicit clean-up, one will be able to instead leverage automatic, Python-owned lifetimes.
§Trademark Notice
Apache Arrow is a trademark of the Apache Software Foundation, used here under fair-use to implement its published interoperability standard as per https://www.apache.org/foundation/marks/ .
Structs§
- Arrow
Array - ArrowArray as per the Arrow C spec
- Arrow
Array Stream - ArrowArrayStream as per the Arrow C Stream Interface spec.
- Arrow
Schema - ArrowSchema as per the Arrow C spec
Functions§
- decode_
arrow_ ⚠metadata - Decodes Arrow C Data Interface metadata from a raw pointer into key-value pairs.
- export_
array_ stream - Creates an ArrowArrayStream that yields plain arrays (one per chunk).
- export_
record_ batch_ stream - Creates an ArrowArrayStream that yields record batches as struct arrays.
- export_
record_ batch_ stream_ with_ metadata - Like
export_record_batch_stream, but attaches key-value metadata to the struct-level schema. Use this to preserve a table name or other metadata across the FFI boundary. - export_
struct_ to_ c - Exports a single record batch (a set of column arrays with a shared schema) as an Arrow struct array + struct schema pair.
- export_
to_ c - Exports a Minarrow array to Arrow C Data Interface pointers.
- fmt_c
- Constructs the Arrow C FFI format string for the given ArrowType.
- import_
array_ ⚠stream - Consumes an ArrowArrayStream that yields plain arrays and returns the imported arrays along with the field metadata.
- import_
from_ ⚠c - Imports a Minarrow array from ArrowArray and ArrowSchema C pointers.
- import_
from_ ⚠c_ owned - Imports a Minarrow array from owned ArrowArray and ArrowSchema C pointers.
- import_
record_ ⚠batch_ stream - Consumes an ArrowArrayStream that yields struct arrays (record batches) and returns a list of Tables.
- import_
record_ ⚠batch_ stream_ with_ metadata - Like
import_record_batch_stream, but also returns the schema-level metadata as key-value pairs. ReturnsNonefor metadata when the schema has no metadata attached.