Struct DeltaEncoder

Source
pub struct DeltaEncoder {
    keyframe_interval: u32,
    threshold: f32,
}
Expand description

Encodes vectors into keyframe + delta sequences.

Configuration:

  • keyframe_interval: store a full vector every K updates
  • threshold: minimum absolute change per dimension to include in delta (ε)

Fields§

§keyframe_interval: u32§threshold: f32

Implementations§

Source§

impl DeltaEncoder

Source

pub fn new(keyframe_interval: u32, threshold: f32) -> Self

Create a new delta encoder.

  • keyframe_interval (K): store a full keyframe every K updates. K=10 means every 10th vector is stored in full.
  • threshold (ε): minimum per-dimension change to include in delta. ε=0.001 means changes smaller than 0.001 are discarded.
Source

pub fn encode( &self, sequence_index: u32, timestamp: i64, vector: &[f32], previous: Option<&[f32]>, ) -> DeltaEntry

Encode a vector, producing either a keyframe or a delta entry.

  • sequence_index: the index of this vector in the entity’s sequence (0, 1, 2, …)
  • timestamp: the timestamp for this vector
  • vector: the full vector
  • previous: the previous full vector (None for the first vector)

Returns a DeltaEntry. If it’s a keyframe, the full vector should be stored separately; if it’s a delta, only the sparse changes are stored.

Source

pub fn keyframe_interval(&self) -> u32

The configured keyframe interval.

Source

pub fn threshold(&self) -> f32

The configured threshold (ε).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.