Struct arrow_array::builder::StructBuilder
source · pub struct StructBuilder { /* private fields */ }
Expand description
Builder for StructArray
Note that callers should make sure that methods of all the child field builders are properly called to maintain the consistency of the data structure.
Implementations§
source§impl StructBuilder
impl StructBuilder
sourcepub fn new(
fields: impl Into<Fields>,
field_builders: Vec<Box<dyn ArrayBuilder>>
) -> Self
pub fn new( fields: impl Into<Fields>, field_builders: Vec<Box<dyn ArrayBuilder>> ) -> Self
Creates a new StructBuilder
sourcepub fn from_fields(fields: impl Into<Fields>, capacity: usize) -> Self
pub fn from_fields(fields: impl Into<Fields>, capacity: usize) -> Self
Creates a new StructBuilder
from Fields
and capacity
sourcepub fn field_builder<T: ArrayBuilder>(&mut self, i: usize) -> Option<&mut T>
pub fn field_builder<T: ArrayBuilder>(&mut self, i: usize) -> Option<&mut T>
Returns a mutable reference to the child field builder at index i
.
Result will be None
if the input type T
provided doesn’t match the actual
field builder’s type.
sourcepub fn num_fields(&self) -> usize
pub fn num_fields(&self) -> usize
Returns the number of fields for the struct this builder is building.
sourcepub fn append(&mut self, is_valid: bool)
pub fn append(&mut self, is_valid: bool)
Appends an element (either null or non-null) to the struct. The actual elements should be appended for each child sub-array in a consistent way.
sourcepub fn append_null(&mut self)
pub fn append_null(&mut self)
Appends a null element to the struct.
sourcepub fn finish(&mut self) -> StructArray
pub fn finish(&mut self) -> StructArray
Builds the StructArray
and reset this builder.
sourcepub fn finish_cloned(&self) -> StructArray
pub fn finish_cloned(&self) -> StructArray
Builds the StructArray
without resetting the builder.
Trait Implementations§
source§impl ArrayBuilder for StructBuilder
impl ArrayBuilder for StructBuilder
source§fn len(&self) -> usize
fn len(&self) -> usize
Returns the number of array slots in the builder.
Note that this always return the first child field builder’s length, and it is the caller’s responsibility to maintain the consistency that all the child field builder should have the equal number of elements.
source§fn finish_cloned(&self) -> ArrayRef
fn finish_cloned(&self) -> ArrayRef
Builds the array without resetting the builder.
source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Returns the builder as a non-mutable Any
reference.
This is most useful when one wants to call non-mutable APIs on a specific builder
type. In this case, one can first cast this into a Any
, and then use
downcast_ref
to get a reference on the specific builder.
source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Returns the builder as a mutable Any
reference.
This is most useful when one wants to call mutable APIs on a specific builder
type. In this case, one can first cast this into a Any
, and then use
downcast_mut
to get a reference on the specific builder.