pub struct DeltaEncoder;Expand description
Stateless delta encoding utilities
Implementations§
Source§impl DeltaEncoder
impl DeltaEncoder
Sourcepub fn encode(old: &[f32], new: &[f32]) -> VectorDelta
pub fn encode(old: &[f32], new: &[f32]) -> VectorDelta
Encode the difference between old and new as a VectorDelta.
scale is set to the maximum absolute value in the delta (useful for quantization).
If old and new have different lengths, the shorter is padded with 0.0.
Sourcepub fn apply(base: &[f32], delta: &VectorDelta) -> Vec<f32>
pub fn apply(base: &[f32], delta: &VectorDelta) -> Vec<f32>
Apply a single delta to base, returning the updated vector.
If base and delta.delta have different lengths, the shorter is padded.
Sourcepub fn apply_sequence(base: &[f32], deltas: &[VectorDelta]) -> Vec<f32>
pub fn apply_sequence(base: &[f32], deltas: &[VectorDelta]) -> Vec<f32>
Apply a sequence of deltas in order to base.
Sourcepub fn compress(delta: &VectorDelta, threshold: f32) -> VectorDelta
pub fn compress(delta: &VectorDelta, threshold: f32) -> VectorDelta
Zero out delta components whose absolute value is below threshold.
Sourcepub fn merge(deltas: &[VectorDelta]) -> Option<VectorDelta>
pub fn merge(deltas: &[VectorDelta]) -> Option<VectorDelta>
Merge multiple deltas into a single combined delta by summing components.
Returns None if deltas is empty.
The merged delta gets id = 0, timestamp = 0, and the scale of the sum.
Sourcepub fn stats(deltas: &[VectorDelta]) -> DeltaStats
pub fn stats(deltas: &[VectorDelta]) -> DeltaStats
Compute statistics about a sequence of deltas.
Sourcepub fn magnitude(delta: &VectorDelta) -> f32
pub fn magnitude(delta: &VectorDelta) -> f32
Compute the L2 magnitude of a single delta (Euclidean norm).
Sourcepub fn quantize_to_i8(delta: &VectorDelta) -> Vec<i8>
pub fn quantize_to_i8(delta: &VectorDelta) -> Vec<i8>
Quantize the delta to int8 range [-127, 127].
Uses the stored scale as the normalisation factor.
A scale of 0.0 results in all-zero output.
Auto Trait Implementations§
impl Freeze for DeltaEncoder
impl RefUnwindSafe for DeltaEncoder
impl Send for DeltaEncoder
impl Sync for DeltaEncoder
impl Unpin for DeltaEncoder
impl UnsafeUnpin for DeltaEncoder
impl UnwindSafe for DeltaEncoder
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.