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 serializationsmallvec/arrayvec-- stack-allocated collections for zero-alloc hot pathsparking_lot-- fast mutex for concurrent delta stream accesssimsimd-- SIMD-accelerated distance computation (optionalsimdfeature)lz4_flex/zstd-- compression backends (optionalcompressionfeature)
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
| Type | Description |
|---|---|
VectorDelta | A computed delta between two vector states |
Delta | Trait for types that represent state changes |
DeltaOp | Individual delta operation (set, add, remove) |
SparseDelta | Delta encoding that only stores changed indices |
DeltaStream | Ordered sequence of deltas for event sourcing |
StreamCheckpoint | Snapshot point in a delta stream |
DeltaWindow | Time-bounded aggregation of deltas |
WindowAggregator | Computes rollup statistics over a delta window |
DeltaCompressor | Applies compression codecs to serialized deltas |
DeltaEncoding | Trait for sparse/dense/hybrid encoding strategies |