Struct arrow::array::PrimitiveRunBuilder
source · pub struct PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,{ /* private fields */ }
Expand description
Builder for RunArray
of PrimitiveArray
§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().values(), &[3, 4, 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 = av.as_primitive::<UInt32Type>();
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 new() -> PrimitiveRunBuilder<R, V>
pub fn new() -> PrimitiveRunBuilder<R, V>
Creates a new PrimitiveRunBuilder
sourcepub fn with_capacity(capacity: usize) -> PrimitiveRunBuilder<R, V>
pub fn with_capacity(capacity: usize) -> PrimitiveRunBuilder<R, V>
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 as ArrowPrimitiveType>::Native>,
)
pub fn append_option( &mut self, value: Option<<V as ArrowPrimitiveType>::Native>, )
Appends optional value to the logical array encoded by the RunArray.
sourcepub fn append_value(&mut self, value: <V as ArrowPrimitiveType>::Native)
pub fn append_value(&mut self, value: <V as ArrowPrimitiveType>::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.
Trait Implementations§
source§impl<R, V> ArrayBuilder for PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
impl<R, V> ArrayBuilder for PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
source§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.
source§fn into_box_any(self: Box<PrimitiveRunBuilder<R, V>>) -> Box<dyn Any>
fn into_box_any(self: Box<PrimitiveRunBuilder<R, V>>) -> Box<dyn Any>
Returns the boxed builder as a box of Any
.
source§fn len(&self) -> usize
fn len(&self) -> usize
Returns the length of logical array encoded by the eventual runs array.
source§fn finish_cloned(&self) -> Arc<dyn Array>
fn finish_cloned(&self) -> Arc<dyn Array>
Builds the array without resetting the builder.
source§impl<R, V> Debug for PrimitiveRunBuilder<R, V>where
R: Debug + RunEndIndexType,
V: Debug + ArrowPrimitiveType,
<V as ArrowPrimitiveType>::Native: Debug,
impl<R, V> Debug for PrimitiveRunBuilder<R, V>where
R: Debug + RunEndIndexType,
V: Debug + ArrowPrimitiveType,
<V as ArrowPrimitiveType>::Native: Debug,
source§impl<R, V> Default for PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
impl<R, V> Default for PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
source§fn default() -> PrimitiveRunBuilder<R, V>
fn default() -> PrimitiveRunBuilder<R, V>
source§impl<R, V> Extend<Option<<V as ArrowPrimitiveType>::Native>> for PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
impl<R, V> Extend<Option<<V as ArrowPrimitiveType>::Native>> for PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
source§fn extend<T>(&mut self, iter: T)
fn extend<T>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)