pub struct StructArrayAssembler {
fields: Vec<FieldRef>,
arrays: Vec<ArrayRef>,
nulls: Option<NullBuffer>,
}Expand description
Assembles a StructArray from completed child arrays.
Unlike StructBuilder, which incrementally builds
child arrays, this assembler combines arrays that have already been built.
§Example
let names = Arc::new(StringArray::from(vec!["one", "two"])) as ArrayRef;
let values = Arc::new(Int32Array::from(vec![1, 2])) as ArrayRef;
// Create struct array with `{name: ..., value: ...}` rows
let array = StructArrayAssembler::new()
.with_field("name", names, false)
.with_field("value", values, false)
.build()
.unwrap();
assert_eq!(array.len(), 2);Fields§
§fields: Vec<FieldRef>§arrays: Vec<ArrayRef>§nulls: Option<NullBuffer>Implementations§
Source§impl StructArrayAssembler
impl StructArrayAssembler
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty StructArrayAssembler.
Sourcepub fn with_field(
self,
field_name: impl Into<String>,
array: ArrayRef,
nullable: bool,
) -> Self
pub fn with_field( self, field_name: impl Into<String>, array: ArrayRef, nullable: bool, ) -> Self
Adds an array with a field constructed from its data type.
Sourcepub fn with_field_ref(self, field: FieldRef, array: ArrayRef) -> Self
pub fn with_field_ref(self, field: FieldRef, array: ArrayRef) -> Self
Adds an array using a caller-supplied field.
This preserves field metadata that would be lost if the field were constructed from the array’s data type alone.
Sourcepub fn with_nulls(self, nulls: NullBuffer) -> Self
pub fn with_nulls(self, nulls: NullBuffer) -> Self
Sets the top-level null buffer for the struct array.
Sourcepub fn build(self) -> Result<StructArray, ArrowError>
pub fn build(self) -> Result<StructArray, ArrowError>
Builds the StructArray.
§Errors
Returns an error if the fields, child arrays, or null buffer have incompatible data types or lengths.
Trait Implementations§
Source§impl Clone for StructArrayAssembler
impl Clone for StructArrayAssembler
Source§impl Debug for StructArrayAssembler
impl Debug for StructArrayAssembler
Auto Trait Implementations§
impl !RefUnwindSafe for StructArrayAssembler
impl !UnwindSafe for StructArrayAssembler
impl Freeze for StructArrayAssembler
impl Send for StructArrayAssembler
impl Sync for StructArrayAssembler
impl Unpin for StructArrayAssembler
impl UnsafeUnpin for StructArrayAssembler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more