Struct arrow_array::builder::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 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.
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§impl<R, V> Debug for PrimitiveRunBuilder<R, V>
impl<R, V> Debug for PrimitiveRunBuilder<R, V>
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§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: IntoIterator<Item = Option<V::Native>>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Option<V::Native>>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Auto Trait Implementations§
impl<R, V> Freeze for PrimitiveRunBuilder<R, V>
impl<R, V> RefUnwindSafe for PrimitiveRunBuilder<R, V>where
<V as ArrowPrimitiveType>::Native: RefUnwindSafe,
<R as ArrowPrimitiveType>::Native: RefUnwindSafe,
impl<R, V> Send for PrimitiveRunBuilder<R, V>
impl<R, V> Sync for PrimitiveRunBuilder<R, V>
impl<R, V> Unpin for PrimitiveRunBuilder<R, V>
impl<R, V> UnwindSafe for PrimitiveRunBuilder<R, V>
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
Mutably borrows from an owned value. Read more