arrow_array::builder

Struct FixedSizeListBuilder

Source
pub struct FixedSizeListBuilder<T: ArrayBuilder> { /* private fields */ }
Expand description

Builder for FixedSizeListArray

use arrow_array::{builder::{Int32Builder, FixedSizeListBuilder}, Array, Int32Array};
let values_builder = Int32Builder::new();
let mut builder = FixedSizeListBuilder::new(values_builder, 3);

//  [[0, 1, 2], null, [3, null, 5], [6, 7, null]]
builder.values().append_value(0);
builder.values().append_value(1);
builder.values().append_value(2);
builder.append(true);
builder.values().append_null();
builder.values().append_null();
builder.values().append_null();
builder.append(false);
builder.values().append_value(3);
builder.values().append_null();
builder.values().append_value(5);
builder.append(true);
builder.values().append_value(6);
builder.values().append_value(7);
builder.values().append_null();
builder.append(true);
let list_array = builder.finish();
assert_eq!(
    *list_array.value(0),
    Int32Array::from(vec![Some(0), Some(1), Some(2)])
);
assert!(list_array.is_null(1));
assert_eq!(
    *list_array.value(2),
    Int32Array::from(vec![Some(3), None, Some(5)])
);
assert_eq!(
    *list_array.value(3),
    Int32Array::from(vec![Some(6), Some(7), None])
)

Implementations§

Source§

impl<T: ArrayBuilder> FixedSizeListBuilder<T>

Source

pub fn new(values_builder: T, value_length: i32) -> Self

Creates a new FixedSizeListBuilder from a given values array builder value_length is the number of values within each array

Source

pub fn with_capacity( values_builder: T, value_length: i32, capacity: usize, ) -> Self

Creates a new FixedSizeListBuilder from a given values array builder value_length is the number of values within each array capacity is the number of items to pre-allocate space for in this builder

Source

pub fn with_field(self, field: impl Into<FieldRef>) -> Self

Override the field passed to FixedSizeListArray::new

By default, a nullable field is created with the name item

Note: Self::finish and Self::finish_cloned will panic if the field’s data type does not match that of T

Source§

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

Source

pub fn values(&mut self) -> &mut T

Returns the child array builder as a mutable reference.

This mutable reference can be used to append values into the child array builder, but you must call append to delimit each distinct list value.

Source

pub fn value_length(&self) -> i32

Returns the length of the list

Source

pub fn append(&mut self, is_valid: bool)

Finish the current fixed-length list array slot

Source

pub fn finish(&mut self) -> FixedSizeListArray

Builds the FixedSizeListBuilder and reset this builder.

Source

pub fn finish_cloned(&self) -> FixedSizeListArray

Builds the FixedSizeListBuilder without resetting the builder.

Source

pub fn validity_slice(&self) -> Option<&[u8]>

Returns the current null buffer as a slice

Trait Implementations§

Source§

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

Source§

fn as_any(&self) -> &dyn Any

Returns the builder as a non-mutable Any reference.

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Returns the builder as a mutable Any reference.

Source§

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

Returns the boxed builder as a box of Any.

Source§

fn len(&self) -> usize

Returns the number of array slots in the builder

Source§

fn finish(&mut self) -> ArrayRef

Builds the array and reset this builder.

Source§

fn finish_cloned(&self) -> ArrayRef

Builds the array without resetting the builder.

Source§

fn is_empty(&self) -> bool

Returns whether number of array slots is zero
Source§

impl<T: Debug + ArrayBuilder> Debug for FixedSizeListBuilder<T>

Source§

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

Formats the value using the given formatter. 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
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.

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,