arrow::array

Type Alias BinaryDictionaryBuilder

pub type BinaryDictionaryBuilder<K> = GenericByteDictionaryBuilder<K, GenericBinaryType<i32>>;
Expand description

Builder for DictionaryArray of BinaryArray

// Create a dictionary array indexed by bytes whose values are binary.
// It can thus hold up to 256 distinct binary values.


let mut builder = BinaryDictionaryBuilder::<Int8Type>::new();

// The builder builds the dictionary value by value
builder.append(b"abc").unwrap();
builder.append_null();
builder.append(b"def").unwrap();
builder.append(b"def").unwrap();
builder.append(b"abc").unwrap();
let array = builder.finish();

assert_eq!(
  array.keys(),
  &Int8Array::from(vec![Some(0), None, Some(1), Some(1), Some(0)])
);

// Values are polymorphic and so require a downcast.
let av = array.values();
let ava: &BinaryArray = av.as_any().downcast_ref::<BinaryArray>().unwrap();

assert_eq!(ava.value(0), b"abc");
assert_eq!(ava.value(1), b"def");

Aliased Typeยง

struct BinaryDictionaryBuilder<K> { /* private fields */ }