Struct PartitionedTemporalHnsw

Source
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: PartitionConfig

Configuration.

§global_entity_index: BTreeMap<u64, Vec<(usize, u32)>>

Global entity index: entity_id → vec of (partition_idx, local_node_id).

§total_points: usize

Total number of points across all partitions.

§next_global_id: u32

Next global ID to assign.

§metric: D

Metric (cloned to create new partitions).

Implementations§

Source§

impl<D: DistanceMetric + Clone> PartitionedTemporalHnsw<D>

Source

pub fn new(config: PartitionConfig, metric: D) -> Self

Create a new empty partitioned index.

Source

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.

Source

pub fn insert(&mut self, entity_id: u64, timestamp: i64, vector: &[f32]) -> u32

Insert a temporal point, routing to the correct partition.

Source

pub fn search( &self, query: &[f32], k: usize, filter: TemporalFilter, alpha: f32, query_timestamp: i64, ) -> Vec<(u32, f32)>

Search across relevant partitions, merging results.

Source

pub fn trajectory( &self, entity_id: u64, filter: TemporalFilter, ) -> Vec<(i64, u32)>

Retrieve trajectory for an entity across all partitions.

Source

pub fn vector(&self, global_id: u32) -> Vec<f32>

Get vector by global node ID.

Source

pub fn entity_id(&self, global_id: u32) -> u64

Get entity ID by global node ID.

Source

pub fn timestamp(&self, global_id: u32) -> i64

Get timestamp by global node ID.

Source

pub fn len(&self) -> usize

Total number of indexed points.

Source

pub fn is_empty(&self) -> bool

Whether the index is empty.

Source

pub fn num_partitions(&self) -> usize

Number of partitions.

Source

pub fn partition_info(&self) -> Vec<(i64, i64, usize)>

Get partition info: (start_us, end_us, point_count).

Source

pub fn save(&self, dir: &Path) -> Result<()>

Save all partitions to a directory.

Source

pub fn load(dir: &Path, metric: D) -> Result<Self>

Load partitioned index from a directory.

Source

fn ensure_partition_for(&mut self, timestamp: i64) -> usize

Find or create the partition for a given timestamp.

Source

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>

Source§

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)>

Retrieve trajectory for an entity: (timestamp, node_id) pairs.
Source§

fn vector(&self, node_id: u32) -> Vec<f32>

Get the vector for a node. Returns owned vec for thread safety.
Source§

fn entity_id(&self, node_id: u32) -> u64

Get the entity_id for a node.
Source§

fn timestamp(&self, node_id: u32) -> i64

Get the timestamp for a node.
Source§

fn len(&self) -> usize

Number of points in the index.
Source§

fn is_empty(&self) -> bool

Whether the index is empty.
Source§

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)>

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)>>

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>)>

Smoothed region-distribution trajectory for an entity (RFC-004).
Source§

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)>

Search with metadata filtering (post-filter on search results). Default: ignores metadata filter and delegates to search_raw.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> TemporalSearch for T

Source§

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§

impl<T> TrajectoryAccess for T

Source§

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>

Get the vector for a node. Returns owned vec for thread safety.
Source§

fn entity_id(&self, node_id: u32) -> u64

Get the entity_id for a node.
Source§

fn timestamp(&self, node_id: u32) -> i64

Get the timestamp for a node.
Source§

fn len(&self) -> usize

Number of points in the index.
Source§

fn is_empty(&self) -> bool

Whether the index is empty.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V