pub struct PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,{
run_ends_builder: PrimitiveBuilder<R>,
values_builder: PrimitiveBuilder<V>,
current_value: Option<V::Native>,
current_run_end_index: usize,
prev_run_end_index: usize,
}
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)]));
Fields§
§run_ends_builder: PrimitiveBuilder<R>
§values_builder: PrimitiveBuilder<V>
§current_value: Option<V::Native>
§current_run_end_index: usize
§prev_run_end_index: usize
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.
fn append_run_end(&mut self)
fn append_run_end_with_builders( &self, run_ends_builder: &mut PrimitiveBuilder<R>, values_builder: &mut PrimitiveBuilder<V>, )
fn run_end_index_as_native(&self) -> R::Native
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