ndarrow
Zero-copy bridge between Apache Arrow and ndarray.
ndarrow lets you move data between Arrow and ndarray with zero allocations on the bridge path:
- Arrow → ndarray: borrow Arrow buffers as ndarray views (O(1), no copy)
- ndarray → Arrow: transfer owned ndarray buffers into Arrow arrays (O(1), ownership move)
Quick Example
use Float64Array;
use ;
use Array1;
// Arrow -> ndarray (zero-copy view)
let arrow_array = from;
let view = arrow_array.as_ndarray.unwrap; // ArrayView1<f64>, no allocation
assert_eq!;
// ndarray -> Arrow (zero-copy ownership transfer)
let result = from_vec;
let arrow_result: Float64Array = result.into_arrow.unwrap;
assert_eq!;
Null Handling
Null semantics are explicit at the call site:
use Float64Array;
use AsNdarray;
let array = from;
// Validated: returns Err if nulls present (O(1) check)
let view = array.as_ndarray.unwrap;
// Unchecked: caller guarantees no nulls (zero cost)
let view = unsafe ;
// Masked: returns view + validity bitmap (zero allocation)
let = array.as_ndarray_masked;
Performance Guarantee
Bridge conversions are O(1) regardless of array size. The bridge creates views (pointer + shape) or transfers buffer ownership. It never touches the data.