[−][src]Struct arrow::array::StringDictionaryBuilder
Array builder for DictionaryArray
. For example to map a set of byte indices
to f32 values. Note that the use of a HashMap
here will not scale to very large
arrays or result in an ordered dictionary.
Implementations
impl<K> StringDictionaryBuilder<K> where
K: ArrowDictionaryKeyType,
[src]
K: ArrowDictionaryKeyType,
pub fn new(
keys_builder: PrimitiveBuilder<K>,
values_builder: StringBuilder
) -> Self
[src]
keys_builder: PrimitiveBuilder<K>,
values_builder: StringBuilder
) -> Self
Creates a new StringDictionaryBuilder
from a keys builder and a value builder.
pub fn new_with_dictionary(
keys_builder: PrimitiveBuilder<K>,
dictionary_values: &StringArray
) -> Result<Self>
[src]
keys_builder: PrimitiveBuilder<K>,
dictionary_values: &StringArray
) -> Result<Self>
Creates a new StringDictionaryBuilder
from a keys builder and a dictionary
which is initialized with the given values.
The indices of those dictionary values are used as keys.
Example
use arrow::datatypes::Int16Type; use arrow::array::{StringArray, StringDictionaryBuilder, PrimitiveBuilder}; use std::convert::TryFrom; let dictionary_values = StringArray::try_from(vec![None, Some("abc"), Some("def")]).unwrap(); let mut builder = StringDictionaryBuilder::new_with_dictionary(PrimitiveBuilder::<Int16Type>::new(3), &dictionary_values).unwrap(); builder.append("def").unwrap(); builder.append_null().unwrap(); builder.append("abc").unwrap(); let dictionary_array = builder.finish(); let keys: Vec<Option<i16>> = dictionary_array.keys().collect(); assert_eq!(keys, vec![Some(2), None, Some(1)]);
impl<K> StringDictionaryBuilder<K> where
K: ArrowDictionaryKeyType,
[src]
K: ArrowDictionaryKeyType,
pub fn append(&mut self, value: &str) -> Result<K::Native>
[src]
Append a primitive 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.
pub fn append_null(&mut self) -> Result<()>
[src]
pub fn finish(&mut self) -> DictionaryArray<K>
[src]
Builds the DictionaryArray
and reset this builder.
Trait Implementations
impl<K> ArrayBuilder for StringDictionaryBuilder<K> where
K: ArrowDictionaryKeyType,
[src]
K: ArrowDictionaryKeyType,
fn as_any(&self) -> &dyn Any
[src]
Returns the builder as an non-mutable Any
reference.
fn as_any_mut(&mut self) -> &mut dyn Any
[src]
Returns the builder as an mutable Any
reference.
fn into_box_any(self: Box<Self>) -> Box<dyn Any>
[src]
Returns the boxed builder as a box of Any
.
fn len(&self) -> usize
[src]
Returns the number of array slots in the builder
fn is_empty(&self) -> bool
[src]
Returns whether the number of array slots is zero
fn append_data(&mut self, _data: &[ArrayDataRef]) -> Result<()>
[src]
Appends data from other arrays into the builder
This is most useful when concatenating arrays of the same type into a builder.
fn data_type(&self) -> DataType
[src]
Returns the data type of the builder
This is used for validating array data types in append_data
fn finish(&mut self) -> ArrayRef
[src]
Builds the array and reset this builder.
impl<K: Debug> Debug for StringDictionaryBuilder<K> where
K: ArrowDictionaryKeyType,
K::Native: Debug,
[src]
K: ArrowDictionaryKeyType,
K::Native: Debug,
Auto Trait Implementations
impl<K> RefUnwindSafe for StringDictionaryBuilder<K> where
K: RefUnwindSafe,
<K as ArrowPrimitiveType>::Native: RefUnwindSafe,
K: RefUnwindSafe,
<K as ArrowPrimitiveType>::Native: RefUnwindSafe,
impl<K> Send for StringDictionaryBuilder<K> where
K: Send,
<K as ArrowPrimitiveType>::Native: Send,
K: Send,
<K as ArrowPrimitiveType>::Native: Send,
impl<K> Sync for StringDictionaryBuilder<K> where
K: Sync,
<K as ArrowPrimitiveType>::Native: Sync,
K: Sync,
<K as ArrowPrimitiveType>::Native: Sync,
impl<K> Unpin for StringDictionaryBuilder<K> where
K: Unpin,
<K as ArrowPrimitiveType>::Native: Unpin,
K: Unpin,
<K as ArrowPrimitiveType>::Native: Unpin,
impl<K> UnwindSafe for StringDictionaryBuilder<K> where
K: UnwindSafe,
<K as ArrowPrimitiveType>::Native: UnwindSafe,
K: UnwindSafe,
<K as ArrowPrimitiveType>::Native: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoRequest<T> for T
[src]
fn into_request(self) -> Request<T>
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,