pub struct StringDictionary { /* private fields */ }Expand description
A dictionary-encoded string column.
Each row holds a u32 code into a table of unique values. The value table
is stored Arrow-style as one UTF-8 byte buffer plus n_values() + 1
offsets, so both halves cross an FFI or wasm-bindgen boundary as plain
numeric buffers (Uint32Array codes, Uint8Array bytes, Uint32Array
offsets) and the consumer decodes each unique value once.
Codes are assigned in first-occurrence order, so encoding the same input always yields the same codes.
Implementations§
Source§impl StringDictionary
impl StringDictionary
Sourcepub fn encode<'s>(
values: impl IntoIterator<Item = &'s str>,
) -> Result<Self, BoundaryError>
pub fn encode<'s>( values: impl IntoIterator<Item = &'s str>, ) -> Result<Self, BoundaryError>
Encode a sequence of strings.
Fails with CapacityExceeded
if the row count or total value bytes do not fit in u32.
Sourcepub fn value_bytes(&self) -> &[u8] ⓘ
pub fn value_bytes(&self) -> &[u8] ⓘ
Concatenated UTF-8 bytes of all unique values.
Sourcepub fn value_offsets(&self) -> &[u32]
pub fn value_offsets(&self) -> &[u32]
Offsets into Self::value_bytes; value c spans
value_offsets[c]..value_offsets[c + 1].
Sourcepub fn value(&self, code: u32) -> Option<&str>
pub fn value(&self, code: u32) -> Option<&str>
The unique value for code, or None if the code is out of range.
Trait Implementations§
Source§impl Clone for StringDictionary
impl Clone for StringDictionary
Source§fn clone(&self) -> StringDictionary
fn clone(&self) -> StringDictionary
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StringDictionary
impl Debug for StringDictionary
impl Eq for StringDictionary
Source§impl PartialEq for StringDictionary
impl PartialEq for StringDictionary
impl StructuralPartialEq for StringDictionary
Auto Trait Implementations§
impl Freeze for StringDictionary
impl RefUnwindSafe for StringDictionary
impl Send for StringDictionary
impl Sync for StringDictionary
impl Unpin for StringDictionary
impl UnsafeUnpin for StringDictionary
impl UnwindSafe for StringDictionary
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more