Struct FixedSizeBinaryDictionaryBuilder

pub struct FixedSizeBinaryDictionaryBuilder<K>{
    state: RandomState,
    dedup: HashTable<usize>,
    keys_builder: PrimitiveBuilder<K>,
    values_builder: FixedSizeBinaryBuilder,
    byte_width: i32,
}
Expand description

Builder for DictionaryArray of FixedSizeBinaryArray

The output array has a dictionary of unique, fixed-size binary values. The builder handles deduplication.

§Example

// Build 3 byte FixedBinaryArrays
let byte_width = 3;
let mut builder = FixedSizeBinaryDictionaryBuilder::<Int8Type>::new(3);
builder.append("abc").unwrap();
builder.append_null();
builder.append(b"def").unwrap();
builder.append(b"def").unwrap(); // duplicate value
// Result is a Dictionary Array
let array = builder.finish();
let dict_array = array.as_any().downcast_ref::<DictionaryArray<Int8Type>>().unwrap();
// The array represents "abc", null, "def", "def"
assert_eq!(array.keys().len(), 4);
// but there are only 2 unique values
assert_eq!(array.values().len(), 2);
let values = dict_array.values().as_any().downcast_ref::<FixedSizeBinaryArray>().unwrap();
assert_eq!(values.value(0), "abc".as_bytes());
assert_eq!(values.value(1), "def".as_bytes());

Fields§

§state: RandomState§dedup: HashTable<usize>§keys_builder: PrimitiveBuilder<K>§values_builder: FixedSizeBinaryBuilder§byte_width: i32

Implementations§

§

impl<K> FixedSizeBinaryDictionaryBuilder<K>

pub fn new(byte_width: i32) -> FixedSizeBinaryDictionaryBuilder<K>

Creates a new FixedSizeBinaryDictionaryBuilder

pub fn with_capacity( keys_capacity: usize, value_capacity: usize, byte_width: i32, ) -> FixedSizeBinaryDictionaryBuilder<K>

Creates a new FixedSizeBinaryDictionaryBuilder 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 byte_width: the byte width for individual values in the values array

§

impl<K> FixedSizeBinaryDictionaryBuilder<K>

pub fn append( &mut self, value: impl AsRef<[u8]>, ) -> Result<<K as ArrowPrimitiveType>::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.

pub fn append_null(&mut self)

Appends a null slot into the builder

pub fn append_value(&mut self, value: impl AsRef<[u8]>)

Infallibly append a value to this builder

§Panics

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

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

Builds the DictionaryArray and reset this builder.

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

Builds the DictionaryArray without resetting the builder.

Trait Implementations§

§

impl<K> ArrayBuilder for FixedSizeBinaryDictionaryBuilder<K>

§

fn as_any(&self) -> &(dyn Any + 'static)

Returns the builder as an non-mutable Any reference.

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns the builder as an mutable Any reference.

§

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

Returns the boxed builder as a box of Any.

§

fn len(&self) -> usize

Returns the number of array slots in the builder

§

fn finish(&mut self) -> Arc<dyn Array>

Builds the array and reset this builder.

§

fn finish_cloned(&self) -> Arc<dyn Array>

Builds the array without resetting the builder.

§

fn is_empty(&self) -> bool

Returns whether number of array slots is zero
§

impl<K> Debug for FixedSizeBinaryDictionaryBuilder<K>

§

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

Formats the value using the given formatter. 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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

§

impl<T> Ungil for T
where T: Send,