Expand description
Spatiotemporal HNSW index (ST-HNSW).
Wraps the vanilla HnswGraph with temporal awareness:
- Roaring Bitmaps for O(1) temporal pre-filtering
- Composite distance: $d_{ST} = \alpha \cdot d_{sem} + (1 - \alpha) \cdot d_{time}$
- TemporalFilter integration: snapshot kNN, range kNN
- Trajectory retrieval: all points for an entity ordered by time
ยงExample
use cvx_index::hnsw::{HnswConfig, TemporalHnsw};
use cvx_index::metrics::L2Distance;
use cvx_core::TemporalFilter;
let config = HnswConfig::default();
let mut index = TemporalHnsw::new(config, L2Distance);
// Insert vectors with entity_id and timestamp
index.insert(1, 1000, &[1.0, 0.0, 0.0]);
index.insert(1, 2000, &[0.9, 0.1, 0.0]);
index.insert(2, 1500, &[0.0, 1.0, 0.0]);
// Temporal range search with alpha=0.5
let results = index.search(
&[1.0, 0.0, 0.0],
2,
TemporalFilter::Range(900, 1600),
0.5,
1000, // query timestamp for temporal distance
);
assert_eq!(results.len(), 2); // only 2 points in [900, 1600]Structsยง
- Temporal
Hnsw - Spatiotemporal HNSW index.
- Temporal
Snapshot ๐ - Serializable snapshot of a TemporalHnsw index.
Constantsยง
- SNAPSHOT_
VERSION ๐ - Current snapshot format version. Increment when adding fields.