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 moreSource§impl Debug for RunLengthEncoding
impl Debug for RunLengthEncoding
Auto Trait Implementations§
impl Freeze for RunLengthEncoding
impl RefUnwindSafe for RunLengthEncoding
impl Send for RunLengthEncoding
impl Sync for RunLengthEncoding
impl Unpin for RunLengthEncoding
impl UnwindSafe for RunLengthEncoding
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