Struct UnionBuilder
pub struct UnionBuilder {
len: usize,
fields: BTreeMap<String, FieldData>,
type_id_builder: BufferBuilder<i8>,
value_offset_builder: Option<BufferBuilder<i32>>,
initial_capacity: usize,
}Expand description
Builder for UnionArray
Example: Dense Memory Layout
let mut builder = UnionBuilder::new_dense();
builder.append::<Int32Type>("a", 1).unwrap();
builder.append::<Float64Type>("b", 3.0).unwrap();
builder.append::<Int32Type>("a", 4).unwrap();
let union = builder.build().unwrap();
assert_eq!(union.type_id(0), 0);
assert_eq!(union.type_id(1), 1);
assert_eq!(union.type_id(2), 0);
assert_eq!(union.value_offset(0), 0);
assert_eq!(union.value_offset(1), 0);
assert_eq!(union.value_offset(2), 1);Example: Sparse Memory Layout
let mut builder = UnionBuilder::new_sparse();
builder.append::<Int32Type>("a", 1).unwrap();
builder.append::<Float64Type>("b", 3.0).unwrap();
builder.append::<Int32Type>("a", 4).unwrap();
let union = builder.build().unwrap();
assert_eq!(union.type_id(0), 0);
assert_eq!(union.type_id(1), 1);
assert_eq!(union.type_id(2), 0);
assert_eq!(union.value_offset(0), 0);
assert_eq!(union.value_offset(1), 1);
assert_eq!(union.value_offset(2), 2);Fields§
§len: usize§fields: BTreeMap<String, FieldData>§type_id_builder: BufferBuilder<i8>§value_offset_builder: Option<BufferBuilder<i32>>§initial_capacity: usizeImplementations§
§impl UnionBuilder
impl UnionBuilder
pub fn new_dense() -> UnionBuilder
pub fn new_dense() -> UnionBuilder
Creates a new dense array builder.
pub fn new_sparse() -> UnionBuilder
pub fn new_sparse() -> UnionBuilder
Creates a new sparse array builder.
pub fn with_capacity_dense(capacity: usize) -> UnionBuilder
pub fn with_capacity_dense(capacity: usize) -> UnionBuilder
Creates a new dense array builder with capacity.
pub fn with_capacity_sparse(capacity: usize) -> UnionBuilder
pub fn with_capacity_sparse(capacity: usize) -> UnionBuilder
Creates a new sparse array builder with capacity.
pub fn append_null<T>(&mut self, type_name: &str) -> Result<(), ArrowError>where
T: ArrowPrimitiveType,
pub fn append_null<T>(&mut self, type_name: &str) -> Result<(), ArrowError>where
T: ArrowPrimitiveType,
Appends a null to this builder, encoding the null in the array
of the type_name child / field.
Since UnionArray encodes nulls as an entry in its children
(it doesn’t have a validity bitmap itself), and where the null
is part of the final array, appending a NULL requires
specifying which field (child) to use.
pub fn append<T>(
&mut self,
type_name: &str,
v: <T as ArrowPrimitiveType>::Native,
) -> Result<(), ArrowError>where
T: ArrowPrimitiveType,
pub fn append<T>(
&mut self,
type_name: &str,
v: <T as ArrowPrimitiveType>::Native,
) -> Result<(), ArrowError>where
T: ArrowPrimitiveType,
Appends a value to this builder.
pub fn build(self) -> Result<UnionArray, ArrowError>
pub fn build(self) -> Result<UnionArray, ArrowError>
Builds this builder creating a new UnionArray.
Trait Implementations§
§impl ArrayBuilder for UnionBuilder
impl ArrayBuilder for UnionBuilder
§fn finish_cloned(&self) -> Arc<dyn Array>
fn finish_cloned(&self) -> Arc<dyn Array>
Builds the array without resetting the underlying builder
§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<UnionBuilder>) -> Box<dyn Any>
fn into_box_any(self: Box<UnionBuilder>) -> Box<dyn Any>
Returns the boxed builder as a box of Any
§impl Debug for UnionBuilder
impl Debug for UnionBuilder
§impl Default for UnionBuilder
impl Default for UnionBuilder
§fn default() -> UnionBuilder
fn default() -> UnionBuilder
Auto Trait Implementations§
impl Freeze for UnionBuilder
impl !RefUnwindSafe for UnionBuilder
impl Send for UnionBuilder
impl Sync for UnionBuilder
impl Unpin for UnionBuilder
impl !UnwindSafe for UnionBuilder
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
§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 more