pub struct PartitionedTemporalHnsw<D: DistanceMetric> {
partitions: Vec<Partition<D>>,
config: PartitionConfig,
global_entity_index: BTreeMap<u64, Vec<(usize, u32)>>,
total_points: usize,
next_global_id: u32,
metric: D,
}Expand description
Time-partitioned temporal HNSW index.
Routes inserts to the correct partition by timestamp, prunes queries to only touch relevant partitions, and merges results globally.
Fields§
§partitions: Vec<Partition<D>>Partitions sorted by start time.
config: PartitionConfigConfiguration.
global_entity_index: BTreeMap<u64, Vec<(usize, u32)>>Global entity index: entity_id → vec of (partition_idx, local_node_id).
total_points: usizeTotal number of points across all partitions.
next_global_id: u32Next global ID to assign.
metric: DMetric (cloned to create new partitions).
Implementations§
Source§impl<D: DistanceMetric + Clone> PartitionedTemporalHnsw<D>
impl<D: DistanceMetric + Clone> PartitionedTemporalHnsw<D>
Sourcepub fn new(config: PartitionConfig, metric: D) -> Self
pub fn new(config: PartitionConfig, metric: D) -> Self
Create a new empty partitioned index.
Sourcepub fn from_single(
index: TemporalHnsw<D>,
config: PartitionConfig,
metric: D,
) -> Self
pub fn from_single( index: TemporalHnsw<D>, config: PartitionConfig, metric: D, ) -> Self
Create from an existing TemporalHnsw (migration path).
The entire existing index becomes partition 0.
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 temporal point, routing to the correct partition.
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 relevant partitions, merging results.
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 for an entity across all partitions.
Sourcepub fn num_partitions(&self) -> usize
pub fn num_partitions(&self) -> usize
Number of partitions.
Sourcepub fn partition_info(&self) -> Vec<(i64, i64, usize)>
pub fn partition_info(&self) -> Vec<(i64, i64, usize)>
Get partition info: (start_us, end_us, point_count).
Sourcefn ensure_partition_for(&mut self, timestamp: i64) -> usize
fn ensure_partition_for(&mut self, timestamp: i64) -> usize
Find or create the partition for a given timestamp.
Sourcefn resolve_global_id(&self, global_id: u32) -> (&Partition<D>, u32)
fn resolve_global_id(&self, global_id: u32) -> (&Partition<D>, u32)
Resolve a global node ID to (partition, local_id).
Trait Implementations§
Source§impl<D: DistanceMetric + Clone> TemporalIndexAccess for PartitionedTemporalHnsw<D>
impl<D: DistanceMetric + Clone> TemporalIndexAccess for PartitionedTemporalHnsw<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)>
Source§fn trajectory(&self, entity_id: u64, filter: TemporalFilter) -> Vec<(i64, u32)>
fn trajectory(&self, entity_id: u64, filter: TemporalFilter) -> Vec<(i64, u32)>
Source§fn vector(&self, node_id: u32) -> Vec<f32>
fn vector(&self, node_id: u32) -> Vec<f32>
Source§fn regions(&self, _level: usize) -> Vec<(u32, Vec<f32>, usize)>
fn regions(&self, _level: usize) -> Vec<(u32, Vec<f32>, usize)>
(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)>
(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)>>
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>)>
Source§fn metadata(&self, _node_id: u32) -> HashMap<String, String>
fn metadata(&self, _node_id: u32) -> HashMap<String, String>
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)>
Auto Trait Implementations§
impl<D> Freeze for PartitionedTemporalHnsw<D>where
D: Freeze,
impl<D> RefUnwindSafe for PartitionedTemporalHnsw<D>where
D: RefUnwindSafe,
impl<D> Send for PartitionedTemporalHnsw<D>
impl<D> Sync for PartitionedTemporalHnsw<D>
impl<D> Unpin for PartitionedTemporalHnsw<D>where
D: Unpin,
impl<D> UnwindSafe for PartitionedTemporalHnsw<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
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>
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>
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