pub struct DeltaEncoding { /* private fields */ }Expand description
Stores differences between consecutive values instead of the values themselves.
Pair this with BitPackedInts for maximum compression -
use DeltaBitPacked for the combo.
Implementations§
Source§impl DeltaEncoding
impl DeltaEncoding
Sourcepub fn encode(values: &[u64]) -> Self
pub fn encode(values: &[u64]) -> Self
Encodes a slice of u64 values using delta encoding.
§Requirements
Values must be sorted in ascending order. Unsorted input will produce
incorrect results due to saturating_sub mapping negative deltas to zero.
A debug assertion checks this in debug builds.
For signed or unsorted data, use encode_signed instead.
Sourcepub fn encode_signed(values: &[i64]) -> Self
pub fn encode_signed(values: &[i64]) -> Self
Encodes a slice of i64 values using delta encoding.
Computes signed deltas between consecutive values, then zig-zag encodes the deltas to store them as unsigned integers.
Sourcepub fn decode(&self) -> Vec<u64>
pub fn decode(&self) -> Vec<u64>
Decodes the delta-encoded values back to the original sequence.
Sourcepub fn decode_signed(&self) -> Vec<i64>
pub fn decode_signed(&self) -> Vec<i64>
Decodes to signed integers using zig-zag decoding.
Assumes the encoding was created with encode_signed.
Sourcepub fn max_delta(&self) -> u64
pub fn max_delta(&self) -> u64
Returns the maximum delta value.
Useful for determining bit width for bit-packing.
Sourcepub fn bits_for_max_delta(&self) -> u8
pub fn bits_for_max_delta(&self) -> u8
Returns the number of bits needed to represent the largest delta.
Sourcepub fn compression_ratio(&self) -> f64
pub fn compression_ratio(&self) -> f64
Estimates the compression ratio.
Returns the ratio of original size to compressed size.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Deserializes a delta encoding from bytes.
Trait Implementations§
Source§impl Clone for DeltaEncoding
impl Clone for DeltaEncoding
Source§fn clone(&self) -> DeltaEncoding
fn clone(&self) -> DeltaEncoding
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DeltaEncoding
impl RefUnwindSafe for DeltaEncoding
impl Send for DeltaEncoding
impl Sync for DeltaEncoding
impl Unpin for DeltaEncoding
impl UnwindSafe for DeltaEncoding
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