pub struct StringDictionary { /* private fields */ }Expand description
A dictionary-encoded string column.
Implementations§
Source§impl StringDictionary
impl StringDictionary
Sourcepub fn encode(strings: &[Option<&str>]) -> (Self, Vec<u32>)
pub fn encode(strings: &[Option<&str>]) -> (Self, Vec<u32>)
Encode a batch of strings, returning (dictionary, encoded_ids).
The dictionary contains unique strings. encoded_ids is a Vec<u32>
where each entry is the dictionary ID for the corresponding input string.
Unknown/NULL strings get ID u32::MAX.
Sourcepub fn lookup(&self, id: u32) -> Option<&str>
pub fn lookup(&self, id: u32) -> Option<&str>
Look up a string by ID. Returns None if ID is out of range.
Sourcepub fn lookup_id(&self, s: &str) -> Option<u32>
pub fn lookup_id(&self, s: &str) -> Option<u32>
Look up a string value and return its ID. Returns None if not found.
Sourcepub fn serialize(&self) -> Vec<u8> ⓘ
pub fn serialize(&self) -> Vec<u8> ⓘ
Serialize the dictionary to bytes.
Format: [num_strings: u32][for each string: [len: u32][bytes...]]
Sourcepub fn deserialize(data: &[u8]) -> Result<Self>
pub fn deserialize(data: &[u8]) -> Result<Self>
Deserialize a dictionary from bytes.
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Compute the memory usage in bytes.
Trait Implementations§
Source§impl Clone for StringDictionary
impl Clone for StringDictionary
Source§fn clone(&self) -> StringDictionary
fn clone(&self) -> StringDictionary
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StringDictionary
impl Debug 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§
impl<T> Allocation for T
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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