pub struct DoraArray(/* private fields */);Expand description
A dora payload: an Apache Arrow array owned by dora.
DoraArray is the counterpart to IntoArrow: dora node APIs hand
received outputs to nodes as DoraArray, which is read back into plain
Rust values through its TryFrom<&DoraArray> implementations.
The wrapped Arrow array is private. That is the whole point of the type: it is what lets dora change its internal Arrow major without breaking the 1.x contract. To reach the Arrow array itself, enable the feature naming the major you want — see the crate-level docs.
Two conversion shapes are provided, with different length contracts:
- Scalar conversions (
bool, the primitive integer/float types,String,&str, and thechronodate/time types) require the array to hold exactly one element and no nulls; any other length is an error. - Slice /
Vecconversions (&[T]andVec<T>for the primitive types) accept any length but still reject any null values.
§Example
use dora_arrow_convert::{DoraArray, IntoArrow};
// Scalar: a single-element array converts to the value.
let data: DoraArray = 42_u8.into_arrow();
let scalar: u8 = (&data).try_into()?;
assert_eq!(scalar, 42);
// Strings follow the same single-element rule.
let data = "hello".to_string().into_arrow();
let text: String = (&data).try_into()?;
assert_eq!(text, "hello");
// Vec: any length, collected into an owned `Vec`.
let data = vec![1_i32, 2, 3].into_arrow();
let values: Vec<i32> = (&data).try_into()?;
assert_eq!(values, vec![1, 2, 3]);
// A multi-element array cannot be read as a scalar.
let data = vec![1_i32, 2, 3].into_arrow();
let scalar: Result<i32, _> = (&data).try_into();
assert!(scalar.is_err());Implementations§
Source§impl DoraArray
impl DoraArray
Sourcepub fn null_count(&self) -> usize
pub fn null_count(&self) -> usize
The number of null elements in the payload.
Sourcepub fn type_name(&self) -> String
pub fn type_name(&self) -> String
A human-readable name for the payload’s Arrow type, e.g. "UInt8" or
"List(Field { name: \"item\", .. })".
Returned as a String rather than an arrow_schema::DataType so that
the ungated surface stays free of Arrow types. Use it for logging and
error messages; to actually inspect the type, take the array through a
version-gated accessor.