Errow.CData (errow v0.1.0)

Copy Markdown View Source

Utilities for exporting Errow arrays to the Apache Arrow C Data Interface specification.

This allows zero-copy consumption by external native libraries such as:

  • DuckDB (duckdb_arrow_scan)
  • Polars / arrow-rs (arrow::ffi::ArrowArray)
  • PyArrow (pyarrow.Array._import_from_c)
  • Custom NIFs in C, Rust, or Zig

Summary

Functions

Exports the raw memory buffers ready to be passed to NIFs or Arrow C Data Interface.

Generates the Arrow C Schema metadata map for an array.

Functions

export_buffers(arr, opts \\ [])

@spec export_buffers(struct(), keyword()) :: map()

Exports the raw memory buffers ready to be passed to NIFs or Arrow C Data Interface.

Returns a map with:

  • :length - Number of elements.
  • :null_count - Number of null values.
  • :buffers - List of binaries padded to 8-byte boundaries as per Arrow spec:

export_schema(arr, opts \\ [])

@spec export_schema(struct(), keyword()) :: map()

Generates the Arrow C Schema metadata map for an array.

Returns a map containing:

  • :format - The Arrow C format string (e.g. "u", "z", "i", "l", "g", "d:38,0", "w:32").
  • :name - Column name (defaults to empty string "").
  • :flags - Integer bitfield (2 for nullable).
  • :n_buffers - Count of buffers expected (2 for primitives, 3 for variable-length binaries/strings).