pub trait ArrayBuilder: Send {
Show 20 methods
// Required methods
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
fn dtype(&self) -> &DType;
fn len(&self) -> usize;
fn append_zeros(&mut self, n: usize);
unsafe fn append_nulls_unchecked(&mut self, n: usize);
fn append_scalar(&mut self, scalar: &Scalar) -> VortexResult<()>;
fn reserve_exact(&mut self, additional: usize);
unsafe fn set_validity_unchecked(&mut self, validity: Mask);
fn finish(&mut self) -> ArrayRef;
fn finish_into_canonical(&mut self, ctx: &mut ExecutionCtx) -> Canonical;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn append_zero(&mut self) { ... }
fn append_null(&mut self) { ... }
fn append_nulls(&mut self, n: usize) { ... }
fn append_default(&mut self) { ... }
fn append_defaults(&mut self, n: usize) { ... }
fn set_validity(&mut self, validity: Mask) { ... }
fn append_list_array(
&mut self,
array: ArrayView<'_, List>,
_ctx: &mut ExecutionCtx,
) -> VortexResult<()> { ... }
fn append_listview_array(
&mut self,
array: ArrayView<'_, ListView>,
_ctx: &mut ExecutionCtx,
) -> VortexResult<()> { ... }
}Required Methods§
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
fn dtype(&self) -> &DType
fn len(&self) -> usize
Sourcefn append_zeros(&mut self, n: usize)
fn append_zeros(&mut self, n: usize)
Appends n “zero” values to the array.
Zero values are generally determined by Scalar::default_value.
Sourceunsafe fn append_nulls_unchecked(&mut self, n: usize)
unsafe fn append_nulls_unchecked(&mut self, n: usize)
Sourcefn append_scalar(&mut self, scalar: &Scalar) -> VortexResult<()>
fn append_scalar(&mut self, scalar: &Scalar) -> VortexResult<()>
A generic function to append a scalar to the builder.
Sourcefn reserve_exact(&mut self, additional: usize)
fn reserve_exact(&mut self, additional: usize)
Allocate space for extra additional items
Sourceunsafe fn set_validity_unchecked(&mut self, validity: Mask)
unsafe fn set_validity_unchecked(&mut self, validity: Mask)
override validity with the one provided, without checking lengths
§Safety
Given validity must have an equal length to self.len().
Sourcefn finish(&mut self) -> ArrayRef
fn finish(&mut self) -> ArrayRef
Constructs an Array from the builder components.
§Panics
This function may panic if the builder’s methods are called with invalid arguments. If only the methods on this interface are used, the builder should not panic. However, specific builders have interfaces that may be misused. For example, if the number of values in a PrimitiveBuilder’s vortex_buffer::BufferMut does not match the number of validity bits, the PrimitiveBuilder’s Self::finish will panic.
Sourcefn finish_into_canonical(&mut self, ctx: &mut ExecutionCtx) -> Canonical
fn finish_into_canonical(&mut self, ctx: &mut ExecutionCtx) -> Canonical
Provided Methods§
fn is_empty(&self) -> bool
Sourcefn append_zero(&mut self)
fn append_zero(&mut self)
Append a “zero” value to the array.
Zero values are generally determined by Scalar::default_value.
Sourcefn append_null(&mut self)
fn append_null(&mut self)
Append a “null” value to the array.
Implementors should panic if this method is called on a non-nullable ArrayBuilder.
Sourcefn append_nulls(&mut self, n: usize)
fn append_nulls(&mut self, n: usize)
Appends n “null” values to the array.
Implementors should panic if this method is called on a non-nullable ArrayBuilder.
Sourcefn append_default(&mut self)
fn append_default(&mut self)
Appends a default value to the array.
Sourcefn append_defaults(&mut self, n: usize)
fn append_defaults(&mut self, n: usize)
Appends n default values to the array.
If the array builder is nullable, then this has the behavior of self.append_nulls(n).
If the array builder is non-nullable, then it has the behavior of self.append_zeros(n).
Sourcefn set_validity(&mut self, validity: Mask)
fn set_validity(&mut self, validity: Mask)
Override builders validity with the one provided.
Note that this will have no effect on the final array if the array builder is non-nullable.
Sourcefn append_list_array(
&mut self,
array: ArrayView<'_, List>,
_ctx: &mut ExecutionCtx,
) -> VortexResult<()>
fn append_list_array( &mut self, array: ArrayView<'_, List>, _ctx: &mut ExecutionCtx, ) -> VortexResult<()>
Appends the values of a List-encoded array to this builder.
Only list-typed builders support this; the default implementation returns an error. List
encodings dispatch through this method because the concrete list builders are generic over
their offset/size integer types, which cannot be named through a dyn ArrayBuilder.
Sourcefn append_listview_array(
&mut self,
array: ArrayView<'_, ListView>,
_ctx: &mut ExecutionCtx,
) -> VortexResult<()>
fn append_listview_array( &mut self, array: ArrayView<'_, ListView>, _ctx: &mut ExecutionCtx, ) -> VortexResult<()>
Appends the values of a ListView-encoded array to this builder.
See append_list_array; this is the same hook for the canonical
ListViewArray encoding.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".