Skip to main content

StructArrayAssembler

Struct StructArrayAssembler 

Source
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

Source

pub fn new() -> Self

Creates a new empty StructArrayAssembler.

Source

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.

Source

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.

Source

pub fn with_nulls(self, nulls: NullBuffer) -> Self

Sets the top-level null buffer for the struct array.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StructArrayAssembler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StructArrayAssembler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.