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: usizeImplementations§
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.
Sourcepub fn with_data_type(self, data_type: DataType) -> Self
pub fn with_data_type(self, data_type: DataType) -> Self
Overrides the data type of the values child array.
By default, V::DATA_TYPE is used (via PrimitiveBuilder). This
allows setting the timezone of a Timestamp, the precision & scale of a
Decimal, etc.
§Panics
This method panics if values_builder rejects data_type.
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)
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)