Expand description
Contains declarations to bind to the C Data Interface.
Generally, this module is divided in two main interfaces: One interface maps C ABI to native Rust types, i.e. convert c-pointers, c_char, to native rust. This is handled by FFI_ArrowSchema and FFI_ArrowArray.
The second interface maps native Rust types to the Rust-specific implementation of Arrow such as format
to Datatype
,
Buffer
, etc. This is handled by ArrowArray
.
// create an array natively
let array = Int32Array::from(vec![Some(1), None, Some(3)]);
// export it
let (array_ptr, schema_ptr) = array.to_raw()?;
// consumed and used by something else...
// import it
let array = unsafe { make_array_from_raw(array_ptr, schema_ptr)? };
// perform some operation
let array = array.as_any().downcast_ref::<Int32Array>().ok_or(
ArrowError::ParseError("Expects an int32".to_string()),
)?;
let array = arithmetic::add(&array, &array)?;
// verify
assert_eq!(array, Int32Array::from(vec![Some(2), None, Some(6)]));
// (drop/release)
Ok(())
}
Structs
Struct used to move an Array from and to the C Data Interface. Its main responsibility is to expose functionality that requires both FFI_ArrowArray and FFI_ArrowSchema.
ABI-compatible struct for ArrowArray from C Data Interface See https://arrow.apache.org/docs/format/CDataInterface.html#structure-definitions This was created by bindgen
ABI-compatible struct for ArrowSchema
from C Data Interface
See https://arrow.apache.org/docs/format/CDataInterface.html#structure-definitions
This was created by bindgen