Skip to content

spt-delta-core

Core delta types and traits for behavioral vector change tracking

Overview

spt-delta-core provides the fundamental abstractions for computing, applying, and composing deltas on vector data structures. It supports event sourcing via delta streams, time-bounded aggregation via delta windows, and multiple encoding strategies (sparse, dense, run-length, hybrid). This is the foundation for incremental vector updates throughout the SPT database engine.

Key Features

  • Vector delta computation -- compute sparse change sets between two vector states
  • Delta composition -- combine multiple sequential deltas into a single operation
  • Delta streams -- ordered event-sourcing sequences with checkpointing
  • Windowed aggregation -- time-bounded delta rollups for analytics
  • Compression codecs -- LZ4 and Zstd compression for delta storage (optional)

Dependencies

Key internal dependencies:

  • bincode -- binary encoding for compact delta serialization
  • smallvec / arrayvec -- stack-allocated collections for zero-alloc hot paths
  • parking_lot -- fast mutex for concurrent delta stream access
  • simsimd -- SIMD-accelerated distance computation (optional simd feature)
  • lz4_flex / zstd -- compression backends (optional compression feature)

Usage

rust
use spt_delta_core::{VectorDelta, DeltaStream};

let old = vec![1.0f32, 2.0, 3.0];
let new = vec![1.1f32, 2.0, 3.5];
let delta = VectorDelta::compute(&old, &new);

let mut reconstructed = old.clone();
delta.apply(&mut reconstructed).unwrap();

API Reference

Core Types

TypeDescription
VectorDeltaA computed delta between two vector states
DeltaTrait for types that represent state changes
DeltaOpIndividual delta operation (set, add, remove)
SparseDeltaDelta encoding that only stores changed indices
DeltaStreamOrdered sequence of deltas for event sourcing
StreamCheckpointSnapshot point in a delta stream
DeltaWindowTime-bounded aggregation of deltas
WindowAggregatorComputes rollup statistics over a delta window
DeltaCompressorApplies compression codecs to serialized deltas
DeltaEncodingTrait for sparse/dense/hybrid encoding strategies

Released under the MIT License.