pub struct Dictionary<K, V> { /* private fields */ }Expand description
Marker for an arrow Dictionary column, e.g. Dictionary<i32, Utf8>.
Think of Dictionary<K, V> as a column of V, dictionary-compressed:
the encoding is a storage detail, and the element values are those of V
(e.g. &str), looked up through the dictionary keys.
K is the integer key type (i8–i64, u8–u64) — a space/size trade-off,
never user-visible.
§Nullability
Since Dictionary<K, V> is logically a column of V, row nullability works
like for any other column: Option<Dictionary<K, V>> means the rows may be null
(arrow encodes this in the validity bitmap of the keys).
Dictionary<Option<K>, V> would be meaningless: the keys are storage indices,
not values anyone reads — Option<…> always marks nullability of readable values.
Additionally, arrow allows null entries in the dictionary’s value table itself,
so a valid key can point at a null. That (rare) case is Dictionary<K, Option<V>>.
Column<Dictionary<K, V>> (no Option anywhere) guarantees the absence of both.
use quiver::{Column, Dictionary, Utf8};
// Building dictionary-encodes the values (can fail on key overflow):
let column = Column::<Dictionary<i32, Utf8>>::try_from_values(["a", "b", "a"]).unwrap();
assert_eq!(column.value(2), "a"); // transparent: reads like a plain column
assert_eq!(column.to_vec(), ["a", "b", "a"]);This type is never instantiated — it only appears as a type parameter.
Trait Implementations§
Source§impl<K: DictionaryKey + 'static, V: ConcreteType + 'static> ConcreteType for Dictionary<K, V>
impl<K: DictionaryKey + 'static, V: ConcreteType + 'static> ConcreteType for Dictionary<K, V>
Source§impl<K: DictionaryKey + 'static, V: LogicalType + 'static> LogicalType for Dictionary<K, V>
impl<K: DictionaryKey + 'static, V: LogicalType + 'static> LogicalType for Dictionary<K, V>
Source§type Typed = TypedDictionary<K, V>
type Typed = TypedDictionary<K, V>
Source§type Value<'a> = <V as LogicalType>::Value<'a>
type Value<'a> = <V as LogicalType>::Value<'a>
&'a str for Utf8, i64 for i64,
an iterator for List<T>, Option<…> for Option<T>.Source§type Owned = <V as LogicalType>::Owned
type Owned = <V as LogicalType>::Owned
String for Utf8, Option<i64> for Option<i64>, Vec<…> for List<…>, etc.Source§fn downcast(array: &dyn Array) -> Result<Self::Typed, ColumnError>
fn downcast(array: &dyn Array) -> Result<Self::Typed, ColumnError>
array has an acceptable datatype, then recursively
downcasts it — checking the nulls of all children along the way. Read moreSource§fn to_owned_value(value: Self::Value<'_>) -> Self::Owned
fn to_owned_value(value: Self::Value<'_>) -> Self::Owned
&str → String.Source§impl<K: DictionaryKey + 'static, V: RefType + 'static> RefType for Dictionary<K, V>
References are looked up through the dictionary keys, like LogicalType::value.
impl<K: DictionaryKey + 'static, V: RefType + 'static> RefType for Dictionary<K, V>
References are looked up through the dictionary keys, like LogicalType::value.