Skip to main content

ArrayBuilder

Trait ArrayBuilder 

Source
pub trait ArrayBuilder:
    Any
    + Send
    + Sync {
    // Required methods
    fn len(&self) -> usize;
    fn finish(&mut self) -> Arc<dyn Array>;
    fn finish_cloned(&self) -> Arc<dyn Array>;
    fn as_any(&self) -> &(dyn Any + 'static);
    fn as_any_mut(&mut self) -> &mut (dyn Any + 'static);
    fn into_box_any(self: Box<Self>) -> Box<dyn Any>;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Trait for dealing with different array builders at runtime

ยงExample

// Create

let mut data_builders: Vec<Box<dyn ArrayBuilder>> = vec![
    Box::new(Float64Builder::new()),
    Box::new(Int64Builder::new()),
    Box::new(StringBuilder::new()),
];

// Fill
data_builders[0]
    .as_any_mut()
    .downcast_mut::<Float64Builder>()
    .unwrap()
    .append_value(3.14);
data_builders[1]
    .as_any_mut()
    .downcast_mut::<Int64Builder>()
    .unwrap()
    .append_value(-1);
data_builders[2]
    .as_any_mut()
    .downcast_mut::<StringBuilder>()
    .unwrap()
    .append_value("๐ŸŽ");

// Finish
let array_refs: Vec<ArrayRef> = data_builders
    .iter_mut()
    .map(|builder| builder.finish())
    .collect();
assert_eq!(array_refs[0].len(), 1);
assert_eq!(array_refs[1].is_null(0), false);
assert_eq!(
    array_refs[2]
        .as_any()
        .downcast_ref::<StringArray>()
        .unwrap()
        .value(0),
    "๐ŸŽ"
);

Required Methodsยง

Source

fn len(&self) -> usize

Returns the number of array slots in the builder

Source

fn finish(&mut self) -> Arc<dyn Array>

Builds the array

Source

fn finish_cloned(&self) -> Arc<dyn Array>

Builds the array without resetting the underlying builder.

Source

fn as_any(&self) -> &(dyn Any + 'static)

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 + 'static)

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.

Source

fn into_box_any(self: Box<Self>) -> Box<dyn Any>

Returns the boxed builder as a box of Any.

Provided Methodsยง

Source

fn is_empty(&self) -> bool

Returns whether number of array slots is zero

Trait Implementationsยง

Sourceยง

impl ArrayBuilder for Box<dyn ArrayBuilder>

Sourceยง

fn len(&self) -> usize

Returns the number of array slots in the builder
Sourceยง

fn is_empty(&self) -> bool

Returns whether number of array slots is zero
Sourceยง

fn finish(&mut self) -> Arc<dyn Array>

Builds the array
Sourceยง

fn finish_cloned(&self) -> Arc<dyn Array>

Builds the array without resetting the underlying builder.
Sourceยง

fn as_any(&self) -> &(dyn Any + 'static)

Returns the builder as a non-mutable Any reference. Read more
Sourceยง

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns the builder as a mutable Any reference. Read more
Sourceยง

fn into_box_any(self: Box<Box<dyn ArrayBuilder>>) -> Box<dyn Any>

Returns the boxed builder as a box of Any.

Implementorsยง

Sourceยง

impl ArrayBuilder for BooleanBuilder

Sourceยง

impl ArrayBuilder for FixedSizeBinaryBuilder

Sourceยง

impl ArrayBuilder for NullBuilder

Sourceยง

impl ArrayBuilder for StructBuilder

Sourceยง

impl ArrayBuilder for UnionBuilder

Sourceยง

impl ArrayBuilder for Box<dyn ArrayBuilder>

Sourceยง

impl<K> ArrayBuilder for FixedSizeBinaryDictionaryBuilder<K>

Sourceยง

impl<K, T> ArrayBuilder for GenericByteDictionaryBuilder<K, T>

Sourceยง

impl<K, V> ArrayBuilder for MapBuilder<K, V>

Sourceยง

impl<K, V> ArrayBuilder for PrimitiveDictionaryBuilder<K, V>

Sourceยง

impl<OffsetSize, T> ArrayBuilder for GenericListBuilder<OffsetSize, T>
where OffsetSize: OffsetSizeTrait, T: ArrayBuilder + 'static,

Sourceยง

impl<OffsetSize, T> ArrayBuilder for GenericListViewBuilder<OffsetSize, T>
where OffsetSize: OffsetSizeTrait, T: ArrayBuilder,

Sourceยง

impl<R, V> ArrayBuilder for GenericByteRunBuilder<R, V>

Sourceยง

impl<R, V> ArrayBuilder for PrimitiveRunBuilder<R, V>

Sourceยง

impl<T> ArrayBuilder for FixedSizeListBuilder<T>
where T: ArrayBuilder + 'static,

Sourceยง

impl<T> ArrayBuilder for GenericByteBuilder<T>
where T: ByteArrayType,

Sourceยง

impl<T> ArrayBuilder for GenericByteViewBuilder<T>
where T: ByteViewType + ?Sized,

Sourceยง

impl<T> ArrayBuilder for PrimitiveBuilder<T>