pub struct DictionaryRleEncoder;Expand description
Dictionary + Run-Length Encoding Hybrid
Combines dictionary encoding with run-length encoding for high repetition data. Perfect for categorical columns with repeated values.
§Examples
ⓘ
let values = vec!["NY", "NY", "NY", "TX", "TX", "CA"];
let (encoded, dict) = DictionaryRleEncoder::compress_with_rle(&values)?;
// Dictionary: {"NY": 0, "TX": 1, "CA": 2}
// Encoded: [(0, 3), (1, 2), (2, 1)] // (value, count) pairs
// Compression: 6 values → 3 runs = 50% reductionImplementations§
Source§impl DictionaryRleEncoder
impl DictionaryRleEncoder
Sourcepub fn compress_with_rle(
values: &[&str],
) -> Result<(Vec<u8>, HashMap<String, u32>), BinaryFormatError>
pub fn compress_with_rle( values: &[&str], ) -> Result<(Vec<u8>, HashMap<String, u32>), BinaryFormatError>
Compress strings using dictionary + RLE
Returns (compressed runs, dictionary) Runs are encoded as (dict_id, count) pairs
Sourcepub fn decompress_rle(
bytes: &[u8],
dictionary: &HashMap<String, u32>,
) -> Result<Vec<String>, BinaryFormatError>
pub fn decompress_rle( bytes: &[u8], dictionary: &HashMap<String, u32>, ) -> Result<Vec<String>, BinaryFormatError>
Decompress RLE-encoded values
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DictionaryRleEncoder
impl RefUnwindSafe for DictionaryRleEncoder
impl Send for DictionaryRleEncoder
impl Sync for DictionaryRleEncoder
impl Unpin for DictionaryRleEncoder
impl UnsafeUnpin for DictionaryRleEncoder
impl UnwindSafe for DictionaryRleEncoder
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