Struct StructArrayAssembler
pub struct StructArrayAssembler {
fields: Vec<Arc<Field>>,
arrays: Vec<Arc<dyn Array>>,
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<Arc<Field>>§arrays: Vec<Arc<dyn Array>>§nulls: Option<NullBuffer>Implementations§
§impl StructArrayAssembler
impl StructArrayAssembler
pub fn new() -> StructArrayAssembler
pub fn new() -> StructArrayAssembler
Creates a new empty StructArrayAssembler.
pub fn with_field(
self,
field_name: impl Into<String>,
array: Arc<dyn Array>,
nullable: bool,
) -> StructArrayAssembler
pub fn with_field( self, field_name: impl Into<String>, array: Arc<dyn Array>, nullable: bool, ) -> StructArrayAssembler
Adds an array with a field constructed from its data type.
pub fn with_field_ref(
self,
field: Arc<Field>,
array: Arc<dyn Array>,
) -> StructArrayAssembler
pub fn with_field_ref( self, field: Arc<Field>, array: Arc<dyn Array>, ) -> StructArrayAssembler
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.
pub fn with_nulls(self, nulls: NullBuffer) -> StructArrayAssembler
pub fn with_nulls(self, nulls: NullBuffer) -> StructArrayAssembler
Sets the top-level null buffer for the struct array.
pub 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§
§impl Clone for StructArrayAssembler
impl Clone for StructArrayAssembler
§fn clone(&self) -> StructArrayAssembler
fn clone(&self) -> StructArrayAssembler
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for StructArrayAssembler
impl Debug for StructArrayAssembler
§impl Default for StructArrayAssembler
impl Default for StructArrayAssembler
§fn default() -> StructArrayAssembler
fn default() -> StructArrayAssembler
Returns the “default value” for a type. Read more
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