pub struct RunLengthEncoding { /* private fields */ }Expand description
Run-length encoded data for u64 values.
Stores sequences of (value, count) pairs. Achieves excellent compression when data has long runs of repeated values.
Implementations§
Source§impl RunLengthEncoding
impl RunLengthEncoding
Sourcepub fn from_runs(runs: Vec<Run<u64>>) -> Self
pub fn from_runs(runs: Vec<Run<u64>>) -> Self
Creates a run-length encoding from pre-built runs.
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Returns the total number of values represented.
Sourcepub fn compression_ratio(&self) -> f64
pub fn compression_ratio(&self) -> f64
Returns the compression ratio (original size / encoded size).
Values > 1.0 indicate compression, < 1.0 indicate expansion.
Sourcepub fn is_beneficial(&self) -> bool
pub fn is_beneficial(&self) -> bool
Returns true if run-length encoding is beneficial for this data.
Returns true when compression ratio > 1.0 (actual compression achieved).
Sourcepub fn encoded_size(&self) -> usize
pub fn encoded_size(&self) -> usize
Returns the memory size in bytes of the encoded representation.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Deserializes run-length encoding from bytes.
Sourcepub fn get(&self, index: usize) -> Option<u64>
pub fn get(&self, index: usize) -> Option<u64>
Gets the value at a specific index without full decompression.
Returns None if index is out of bounds.
Sourcepub fn iter(&self) -> RunLengthIterator<'_> ⓘ
pub fn iter(&self) -> RunLengthIterator<'_> ⓘ
Returns an iterator over the decoded values.
Trait Implementations§
Source§impl Clone for RunLengthEncoding
impl Clone for RunLengthEncoding
Source§fn clone(&self) -> RunLengthEncoding
fn clone(&self) -> RunLengthEncoding
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more