pub struct DeltaEncoding { /* private fields */ }Expand description
Delta-encoded integer sequence.
Stores a base value and the deltas between consecutive values. Effective for sorted sequences where deltas are small.
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.
For best compression, values should be sorted in ascending order.
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 more