Struct FixedSizeListBuilder
pub struct FixedSizeListBuilder<T>where
T: ArrayBuilder,{
null_buffer_builder: NullBufferBuilder,
values_builder: T,
list_len: i32,
field: Option<Arc<Field>>,
}
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])
)
Fields§
§null_buffer_builder: NullBufferBuilder
§values_builder: T
§list_len: i32
§field: Option<Arc<Field>>
Implementations§
§impl<T> FixedSizeListBuilder<T>where
T: ArrayBuilder,
impl<T> FixedSizeListBuilder<T>where
T: ArrayBuilder,
pub fn new(values_builder: T, value_length: i32) -> FixedSizeListBuilder<T>
pub fn new(values_builder: T, value_length: i32) -> FixedSizeListBuilder<T>
Creates a new FixedSizeListBuilder
from a given values array builder
value_length
is the number of values within each array
pub fn with_capacity(
values_builder: T,
value_length: i32,
capacity: usize,
) -> FixedSizeListBuilder<T>
pub fn with_capacity( values_builder: T, value_length: i32, capacity: usize, ) -> FixedSizeListBuilder<T>
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
pub fn with_field(self, field: impl Into<Arc<Field>>) -> FixedSizeListBuilder<T>
pub fn with_field(self, field: impl Into<Arc<Field>>) -> FixedSizeListBuilder<T>
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
§impl<T> FixedSizeListBuilder<T>where
T: ArrayBuilder + 'static,
impl<T> FixedSizeListBuilder<T>where
T: ArrayBuilder + 'static,
pub fn values(&mut self) -> &mut T
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.
pub fn value_length(&self) -> i32
pub fn value_length(&self) -> i32
Returns the length of the list
pub fn finish(&mut self) -> FixedSizeListArray
pub fn finish(&mut self) -> FixedSizeListArray
Builds the FixedSizeListBuilder
and reset this builder.
pub fn finish_cloned(&self) -> FixedSizeListArray
pub fn finish_cloned(&self) -> FixedSizeListArray
Builds the FixedSizeListBuilder
without resetting the builder.
pub fn validity_slice(&self) -> Option<&[u8]>
pub fn validity_slice(&self) -> Option<&[u8]>
Returns the current null buffer as a slice
Trait Implementations§
§impl<T> ArrayBuilder for FixedSizeListBuilder<T>where
T: ArrayBuilder + 'static,
impl<T> ArrayBuilder for FixedSizeListBuilder<T>where
T: ArrayBuilder + 'static,
§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Returns the builder as a mutable Any
reference.
§fn into_box_any(self: Box<FixedSizeListBuilder<T>>) -> Box<dyn Any>
fn into_box_any(self: Box<FixedSizeListBuilder<T>>) -> Box<dyn Any>
Returns the boxed builder as a box of Any
.
§fn finish_cloned(&self) -> Arc<dyn Array>
fn finish_cloned(&self) -> Arc<dyn Array>
Builds the array without resetting the builder.
Auto Trait Implementations§
impl<T> Freeze for FixedSizeListBuilder<T>where
T: Freeze,
impl<T> RefUnwindSafe for FixedSizeListBuilder<T>where
T: RefUnwindSafe,
impl<T> Send for FixedSizeListBuilder<T>
impl<T> Sync for FixedSizeListBuilder<T>
impl<T> Unpin for FixedSizeListBuilder<T>where
T: Unpin,
impl<T> UnwindSafe for FixedSizeListBuilder<T>where
T: UnwindSafe,
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request