pub struct StreamingTemporalHnsw<D: DistanceMetric + Clone> {
buffer: HotBuffer,
compacted: PartitionedTemporalHnsw<D>,
config: StreamingConfig,
metric: D,
next_global_id: u32,
compaction_count: usize,
}Expand description
Streaming temporal index that combines a hot buffer with a compacted partitioned HNSW index.
Fields§
§buffer: HotBufferHot buffer for recent writes.
compacted: PartitionedTemporalHnsw<D>Compacted partitioned index.
config: StreamingConfigConfiguration.
metric: DMetric instance.
next_global_id: u32Next global ID to assign.
compaction_count: usizeNumber of compactions performed.
Implementations§
Source§impl<D: DistanceMetric + Clone> StreamingTemporalHnsw<D>
impl<D: DistanceMetric + Clone> StreamingTemporalHnsw<D>
Sourcepub fn new(config: StreamingConfig, metric: D) -> Self
pub fn new(config: StreamingConfig, metric: D) -> Self
Create a new streaming index.
Sourcepub fn insert(&mut self, entity_id: u64, timestamp: i64, vector: &[f32]) -> u32
pub fn insert(&mut self, entity_id: u64, timestamp: i64, vector: &[f32]) -> u32
Insert a point. Goes into the hot buffer first.
Triggers compaction if the buffer exceeds capacity.
Sourcepub fn compact(&mut self)
pub fn compact(&mut self)
Manually trigger compaction: flush buffer into the partitioned index.
Sourcepub fn search(
&self,
query: &[f32],
k: usize,
filter: TemporalFilter,
alpha: f32,
query_timestamp: i64,
) -> Vec<(u32, f32)>
pub fn search( &self, query: &[f32], k: usize, filter: TemporalFilter, alpha: f32, query_timestamp: i64, ) -> Vec<(u32, f32)>
Search across both buffer and compacted index.
Sourcepub fn trajectory(
&self,
entity_id: u64,
filter: TemporalFilter,
) -> Vec<(i64, u32)>
pub fn trajectory( &self, entity_id: u64, filter: TemporalFilter, ) -> Vec<(i64, u32)>
Retrieve trajectory across buffer and compacted index.
Sourcepub fn vector(&self, global_id: u32) -> Vec<f32>
pub fn vector(&self, global_id: u32) -> Vec<f32>
Get vector by global node ID (checks buffer first, then compacted).
Sourcepub fn buffer_len(&self) -> usize
pub fn buffer_len(&self) -> usize
Number of points in the hot buffer.
Sourcepub fn compacted_len(&self) -> usize
pub fn compacted_len(&self) -> usize
Number of points in the compacted index.
Sourcepub fn compaction_count(&self) -> usize
pub fn compaction_count(&self) -> usize
Number of compactions performed.
Trait Implementations§
Source§impl<D: DistanceMetric + Clone> TemporalIndexAccess for StreamingTemporalHnsw<D>
impl<D: DistanceMetric + Clone> TemporalIndexAccess for StreamingTemporalHnsw<D>
Source§fn search_raw(
&self,
query: &[f32],
k: usize,
filter: TemporalFilter,
alpha: f32,
query_timestamp: i64,
) -> Vec<(u32, f32)>
fn search_raw( &self, query: &[f32], k: usize, filter: TemporalFilter, alpha: f32, query_timestamp: i64, ) -> Vec<(u32, f32)>
Search with temporal filtering, returning (node_id, score) pairs.
Source§fn trajectory(&self, entity_id: u64, filter: TemporalFilter) -> Vec<(i64, u32)>
fn trajectory(&self, entity_id: u64, filter: TemporalFilter) -> Vec<(i64, u32)>
Retrieve trajectory for an entity: (timestamp, node_id) pairs.
Source§fn vector(&self, node_id: u32) -> Vec<f32>
fn vector(&self, node_id: u32) -> Vec<f32>
Get the vector for a node. Returns owned vec for thread safety.
Source§fn regions(&self, _level: usize) -> Vec<(u32, Vec<f32>, usize)>
fn regions(&self, _level: usize) -> Vec<(u32, Vec<f32>, usize)>
Get semantic regions at a given HNSW level (RFC-004).
Returns
(hub_node_id, hub_vector, n_assigned) per region.Source§fn region_members(
&self,
_region_hub: u32,
_level: usize,
_filter: TemporalFilter,
) -> Vec<(u32, u64, i64)>
fn region_members( &self, _region_hub: u32, _level: usize, _filter: TemporalFilter, ) -> Vec<(u32, u64, i64)>
Get points belonging to a specific region, optionally time-filtered (RFC-005).
Returns
(node_id, entity_id, timestamp) per member.Source§fn region_assignments(
&self,
_level: usize,
_filter: TemporalFilter,
) -> HashMap<u32, Vec<(u64, i64)>>
fn region_assignments( &self, _level: usize, _filter: TemporalFilter, ) -> HashMap<u32, Vec<(u64, i64)>>
Assign all nodes to regions in a single O(N) pass, optionally time-filtered.
Returns HashMap<hub_id, Vec<(entity_id, timestamp)>>.
Source§fn region_trajectory(
&self,
_entity_id: u64,
_level: usize,
_window_days: i64,
_alpha: f32,
) -> Vec<(i64, Vec<f32>)>
fn region_trajectory( &self, _entity_id: u64, _level: usize, _window_days: i64, _alpha: f32, ) -> Vec<(i64, Vec<f32>)>
Smoothed region-distribution trajectory for an entity (RFC-004).
Source§fn metadata(&self, _node_id: u32) -> HashMap<String, String>
fn metadata(&self, _node_id: u32) -> HashMap<String, String>
Get metadata for a node. Returns empty map if not available.
Source§fn search_with_metadata(
&self,
query: &[f32],
k: usize,
filter: TemporalFilter,
alpha: f32,
query_timestamp: i64,
metadata_filter: &MetadataFilter,
) -> Vec<(u32, f32)>
fn search_with_metadata( &self, query: &[f32], k: usize, filter: TemporalFilter, alpha: f32, query_timestamp: i64, metadata_filter: &MetadataFilter, ) -> Vec<(u32, f32)>
Search with metadata filtering (post-filter on search results).
Default: ignores metadata filter and delegates to search_raw.
Auto Trait Implementations§
impl<D> Freeze for StreamingTemporalHnsw<D>where
D: Freeze,
impl<D> RefUnwindSafe for StreamingTemporalHnsw<D>where
D: RefUnwindSafe,
impl<D> Send for StreamingTemporalHnsw<D>
impl<D> Sync for StreamingTemporalHnsw<D>
impl<D> Unpin for StreamingTemporalHnsw<D>where
D: Unpin,
impl<D> UnwindSafe for StreamingTemporalHnsw<D>where
D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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