Struct arrow_array::builder::PrimitiveRunBuilder
source · pub struct PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,{ /* private fields */ }
Expand description
Array builder for RunArray
that encodes primitive values.
Example:
let mut builder =
PrimitiveRunBuilder::<Int16Type, UInt32Type>::new();
builder.append_value(1234);
builder.append_value(1234);
builder.append_value(1234);
builder.append_null();
builder.append_value(5678);
builder.append_value(5678);
let array = builder.finish();
assert_eq!(
array.run_ends(),
&Int16Array::from(vec![Some(3), Some(4), Some(6)])
);
let av = array.values();
assert!(!av.is_null(0));
assert!(av.is_null(1));
assert!(!av.is_null(2));
// Values are polymorphic and so require a downcast.
let ava: &UInt32Array = as_primitive_array::<UInt32Type>(av.as_ref());
assert_eq!(ava, &UInt32Array::from(vec![Some(1234), None, Some(5678)]));
Implementations§
source§impl<R, V> PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
impl<R, V> PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new PrimitiveRunBuilder
with the provided capacity
capacity
: the expected number of run-end encoded values.
source§impl<R, V> PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
impl<R, V> PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
sourcepub fn append_option(&mut self, value: Option<V::Native>)
pub fn append_option(&mut self, value: Option<V::Native>)
Appends optional value to the logical array encoded by the RunArray.
sourcepub fn append_value(&mut self, value: V::Native)
pub fn append_value(&mut self, value: V::Native)
Appends value to the logical array encoded by the run-ends array.
sourcepub fn append_null(&mut self)
pub fn append_null(&mut self)
Appends null to the logical array encoded by the run-ends array.
sourcepub fn finish(&mut self) -> RunArray<R>
pub fn finish(&mut self) -> RunArray<R>
Creates the RunArray and resets the builder. Panics if RunArray cannot be built.
sourcepub fn finish_cloned(&self) -> RunArray<R>
pub fn finish_cloned(&self) -> RunArray<R>
Creates the RunArray and without resetting the builder. Panics if RunArray cannot be built.