pub struct DictionaryCompressor;Expand description
Dictionary compression for categorical data
Replaces frequently occurring values with indices into a dictionary. Excellent for high-cardinality categorical columns.
§Examples
ⓘ
let values = vec!["red", "blue", "red", "green", "blue", "red"];
let (compressed, dict) = DictionaryCompressor::compress(&values)?;
// Dictionary: {"red": 0, "blue": 1, "green": 2}
// Compressed: [0, 1, 0, 2, 1, 0]Implementations§
Source§impl DictionaryCompressor
impl DictionaryCompressor
Sourcepub fn compress_strings(
values: &[&str],
) -> Result<(Vec<u8>, HashMap<String, u32>), BinaryFormatError>
pub fn compress_strings( values: &[&str], ) -> Result<(Vec<u8>, HashMap<String, u32>), BinaryFormatError>
Compress string values using dictionary encoding
Returns (compressed indices, dictionary)
Sourcepub fn decompress_strings(
bytes: &[u8],
dictionary: &HashMap<String, u32>,
) -> Result<Vec<String>, BinaryFormatError>
pub fn decompress_strings( bytes: &[u8], dictionary: &HashMap<String, u32>, ) -> Result<Vec<String>, BinaryFormatError>
Decompress dictionary-encoded values
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DictionaryCompressor
impl RefUnwindSafe for DictionaryCompressor
impl Send for DictionaryCompressor
impl Sync for DictionaryCompressor
impl Unpin for DictionaryCompressor
impl UnsafeUnpin for DictionaryCompressor
impl UnwindSafe for DictionaryCompressor
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
Mutably borrows from an owned value. Read more