Skip to main content

DeltaDeduplicator

Struct DeltaDeduplicator 

Source
pub struct DeltaDeduplicator { /* private fields */ }
Expand description

Delta deduplicator using rolling hash and KMP.

Orchestrates the two-phase deduplication approach:

  1. Rolling hash for fast filtering
  2. KMP for exact verification

§Example

let mut dedup = DeltaDeduplicator::new();

// Add accumulated content
dedup.add_accumulated("Hello World");

// Check if a delta is a duplicate
if let Some(new_portion) = dedup.extract_new_content("Hello World!") {
    // "!" is the new portion
    assert_eq!(new_portion, "!");
}

Implementations§

Source§

impl DeltaDeduplicator

Source

pub fn is_likely_snapshot(delta: &str, accumulated: &str) -> bool

Check if delta is likely a snapshot using rolling hash only.

This is a faster O(n) check that may have false positives due to hash collisions. Use extract_new_content for verified results.

§Arguments
  • delta - The incoming delta to check
  • accumulated - The previously accumulated content
§Returns
  • true - Delta may be a snapshot (hash matches)
  • false - Delta is definitely not a snapshot (hash doesn’t match)
Source

pub fn is_likely_snapshot_with_thresholds( delta: &str, accumulated: &str, ) -> bool

Check if delta is likely a snapshot with strong overlap detection.

This is an enhanced version of is_likely_snapshot that applies strong overlap thresholds to prevent false positives on intentional repetitions.

§Strong Overlap Detection

This method only returns true when:

  • The overlap meets minimum character count threshold (default: 30 chars)
  • The overlap meets minimum ratio threshold (default: 50% of delta)
  • The overlap ends at a safe boundary (whitespace/punctuation/newline)
  • Short chunks (< 20 chars) are only deduped if exact match
§Arguments
  • delta - The incoming delta to check
  • accumulated - The previously accumulated content
§Returns
  • true - Delta is a snapshot meeting strong overlap criteria
  • false - Delta is either genuine or overlap is too weak
Source

pub fn extract_new_content_with_thresholds<'a>( delta: &'a str, accumulated: &str, ) -> Option<&'a str>

Extract new content from a snapshot with strong overlap detection.

This is an enhanced version of extract_new_content that only extracts new content when the overlap meets strong overlap thresholds.

§Arguments
  • delta - The incoming delta to check
  • accumulated - The previously accumulated content
§Returns
  • Some(new_portion) - The overlap meets thresholds, returns new portion
  • None - The overlap is too weak or not a snapshot
Source

pub fn clear(&mut self)

Clear all tracked content.

Trait Implementations§

Source§

impl Clone for DeltaDeduplicator

Source§

fn clone(&self) -> DeltaDeduplicator

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeltaDeduplicator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DeltaDeduplicator

Source§

fn default() -> DeltaDeduplicator

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.