Struct arrow_array::builder::GenericByteRunBuilder
source · pub struct GenericByteRunBuilder<R, V>where
R: ArrowPrimitiveType,
V: ByteArrayType,{ /* private fields */ }
Expand description
Array builder for RunArray
for String and Binary types.
Example:
let mut builder =
GenericByteRunBuilder::<Int16Type, BinaryType>::new();
builder.append_value(b"abc");
builder.append_value(b"abc");
builder.append_null();
builder.append_value(b"def");
let array = builder.finish();
assert_eq!(
array.run_ends(),
&Int16Array::from(vec![Some(2), Some(3), Some(4)])
);
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: &BinaryArray = as_generic_binary_array(av.as_ref());
assert_eq!(ava.value(0), b"abc");
assert_eq!(ava.value(2), b"def");
Implementations§
source§impl<R, V> GenericByteRunBuilder<R, V>where
R: ArrowPrimitiveType,
V: ByteArrayType,
impl<R, V> GenericByteRunBuilder<R, V>where
R: ArrowPrimitiveType,
V: ByteArrayType,
sourcepub fn with_capacity(capacity: usize, data_capacity: usize) -> Self
pub fn with_capacity(capacity: usize, data_capacity: usize) -> Self
Creates a new GenericByteRunBuilder
with the provided capacity
capacity
: the expected number of run-end encoded values.
data_capacity
: the expected number of bytes of run end encoded values
source§impl<R, V> GenericByteRunBuilder<R, V>where
R: RunEndIndexType,
V: ByteArrayType,
impl<R, V> GenericByteRunBuilder<R, V>where
R: RunEndIndexType,
V: ByteArrayType,
sourcepub fn append_option(&mut self, input_value: Option<impl AsRef<V::Native>>)
pub fn append_option(&mut self, input_value: Option<impl AsRef<V::Native>>)
Appends optional value to the logical array encoded by the RunArray.
sourcepub fn append_value(&mut self, input_value: impl AsRef<V::Native>)
pub fn append_value(&mut self, input_value: impl AsRef<V::Native>)
Appends value to the logical array encoded by the RunArray.
sourcepub fn append_null(&mut self)
pub fn append_null(&mut self)
Appends null to the logical array encoded by the RunArray.
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.