Struct PrimitiveRunBuilder
pub struct PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,{
run_ends_builder: PrimitiveBuilder<R>,
values_builder: PrimitiveBuilder<V>,
current_value: Option<<V as ArrowPrimitiveType>::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 as ArrowPrimitiveType>::Native>
§current_run_end_index: usize
§prev_run_end_index: usize
Implementations§
§impl<R, V> PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
impl<R, V> PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
pub fn new() -> PrimitiveRunBuilder<R, V>
pub fn new() -> PrimitiveRunBuilder<R, V>
Creates a new PrimitiveRunBuilder
pub 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.
§impl<R, V> PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
impl<R, V> PrimitiveRunBuilder<R, V>where
R: RunEndIndexType,
V: ArrowPrimitiveType,
pub 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.
pub 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.
pub fn append_null(&mut self)
pub fn append_null(&mut self)
Appends null to the logical array encoded by the run-ends array.
pub 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.
pub 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§
§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,
§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<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
.
§fn finish_cloned(&self) -> Arc<dyn Array>
fn finish_cloned(&self) -> Arc<dyn Array>
Builds the array without resetting the builder.
§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,
§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,
§fn default() -> PrimitiveRunBuilder<R, V>
fn default() -> PrimitiveRunBuilder<R, V>
Returns the “default value” for a type. Read more
§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_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