Crate gdelta

Crate gdelta 

Source
Expand description

§gdelta

A fast delta compression algorithm for similar data chunks.

GDelta efficiently encodes the differences between similar data chunks using GEAR rolling hash for pattern matching and variable-length integer encoding for space efficiency.

§Quick Start

use gdelta::{encode, decode};

let base = b"Hello, World!";
let new = b"Hello, Rust!";

// Encode the delta
let delta = encode(new, base).unwrap();

// Decode to recover the new data
let recovered = decode(&delta, base).unwrap();
assert_eq!(recovered, new);

§Algorithm Details

The algorithm works by:

  1. Finding common prefix and suffix between base and new data
  2. Building a hash table of the base data using GEAR rolling hash
  3. Scanning the new data to find matches in the base
  4. Encoding the result as copy and literal instructions

§Performance

GDelta is optimized for:

  • Speed: Faster than Xdelta, Zdelta, Ddelta, and Edelta
  • Similar chunks: Best for data chunks 4KB - 64KB in size
  • Inter-chunk redundancy: Removes redundancy between similar chunks

For maximum compression, combine GDelta with a general-purpose compressor like ZSTD or LZ4.

Enums§

GDeltaError
Errors that can occur during delta encoding or decoding.

Functions§

decode
Decodes delta data using the base data to reconstruct the original.
encode
Encodes the delta between new data and base data.

Type Aliases§

Result
Result type for GDelta operations.