arrow_array::builder

Struct GenericByteDictionaryBuilder

Source
pub struct GenericByteDictionaryBuilder<K, T>{ /* private fields */ }
Expand description

Builder for DictionaryArray of GenericByteArray

For example to map a set of byte indices to String values. Note that the use of a HashMap here will not scale to very large arrays or result in an ordered dictionary.

Implementations§

Source§

impl<K, T> GenericByteDictionaryBuilder<K, T>

Source

pub fn new() -> Self

Creates a new GenericByteDictionaryBuilder

Source

pub fn with_capacity( keys_capacity: usize, value_capacity: usize, data_capacity: usize, ) -> Self

Creates a new GenericByteDictionaryBuilder with the provided capacities

keys_capacity: the number of keys, i.e. length of array to build value_capacity: the number of distinct dictionary values, i.e. size of dictionary data_capacity: the total number of bytes of all distinct bytes in the dictionary

Source

pub fn new_with_dictionary( keys_capacity: usize, dictionary_values: &GenericByteArray<T>, ) -> Result<Self, ArrowError>

Creates a new GenericByteDictionaryBuilder from a keys capacity and a dictionary which is initialized with the given values. The indices of those dictionary values are used as keys.

§Example

let dictionary_values = StringArray::from(vec![None, Some("abc"), Some("def")]);

let mut builder = StringDictionaryBuilder::new_with_dictionary(3, &dictionary_values).unwrap();
builder.append("def").unwrap();
builder.append_null();
builder.append("abc").unwrap();

let dictionary_array = builder.finish();

let keys = dictionary_array.keys();

assert_eq!(keys, &Int16Array::from(vec![Some(2), None, Some(1)]));
Source§

impl<K, T> GenericByteDictionaryBuilder<K, T>

Source

pub fn append( &mut self, value: impl AsRef<T::Native>, ) -> Result<K::Native, ArrowError>

Append a value to the array. Return an existing index if already present in the values array or a new index if the value is appended to the values array.

Returns an error if the new index would overflow the key type.

Source

pub fn append_value(&mut self, value: impl AsRef<T::Native>)

Infallibly append a value to this builder

§Panics

Panics if the resulting length of the dictionary values array would exceed T::Native::MAX

Source

pub fn append_null(&mut self)

Appends a null slot into the builder

Source

pub fn append_option(&mut self, value: Option<impl AsRef<T::Native>>)

Append an Option value into the builder

§Panics

Panics if the resulting length of the dictionary values array would exceed T::Native::MAX

Source

pub fn finish(&mut self) -> DictionaryArray<K>

Builds the DictionaryArray and reset this builder.

Source

pub fn finish_cloned(&self) -> DictionaryArray<K>

Builds the DictionaryArray without resetting the builder.

Trait Implementations§

Source§

impl<K, T> ArrayBuilder for GenericByteDictionaryBuilder<K, T>

Source§

fn as_any(&self) -> &dyn Any

Returns the builder as an non-mutable Any reference.

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Returns the builder as an mutable Any reference.

Source§

fn into_box_any(self: Box<Self>) -> Box<dyn Any>

Returns the boxed builder as a box of Any.

Source§

fn len(&self) -> usize

Returns the number of array slots in the builder

Source§

fn finish(&mut self) -> ArrayRef

Builds the array and reset this builder.

Source§

fn finish_cloned(&self) -> ArrayRef

Builds the array without resetting the builder.

Source§

fn is_empty(&self) -> bool

Returns whether number of array slots is zero
Source§

impl<K, T> Debug for GenericByteDictionaryBuilder<K, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K, T> Default for GenericByteDictionaryBuilder<K, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<K: ArrowDictionaryKeyType, T: ByteArrayType, V: AsRef<T::Native>> Extend<Option<V>> for GenericByteDictionaryBuilder<K, T>

Source§

fn extend<I: IntoIterator<Item = Option<V>>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

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)

🔬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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,