pub struct TemporalLSH {
tables: Vec<HashMap<u64, Vec<u32>>>,
hyperplanes: Vec<Vec<Vec<f32>>>,
config: TLSHConfig,
dim: usize,
n_points: usize,
}Expand description
Temporal Locality-Sensitive Hashing index.
Maintains multiple hash tables where each hash combines semantic (random hyperplane) and temporal (bucket) components.
Fields§
§tables: Vec<HashMap<u64, Vec<u32>>>Hash tables: tables[table_idx][hash] → vec of node_ids.
hyperplanes: Vec<Vec<Vec<f32>>>Random hyperplanes for semantic hashing.
Shape: [n_tables][semantic_bits][dim].
config: TLSHConfigConfiguration.
dim: usizeDimensionality of vectors.
n_points: usizeTotal number of indexed points.
Implementations§
Source§impl TemporalLSH
impl TemporalLSH
Sourcepub fn new(dim: usize, config: TLSHConfig) -> Self
pub fn new(dim: usize, config: TLSHConfig) -> Self
Create a new empty T-LSH index.
Sourcepub fn build(vectors: &[&[f32]], timestamps: &[i64], config: TLSHConfig) -> Self
pub fn build(vectors: &[&[f32]], timestamps: &[i64], config: TLSHConfig) -> Self
Build T-LSH from existing index data.
Sourcepub fn insert(&mut self, node_id: u32, vector: &[f32], timestamp: i64)
pub fn insert(&mut self, node_id: u32, vector: &[f32], timestamp: i64)
Insert a point into all hash tables.
Sourcepub fn query(&self, vector: &[f32], timestamp: i64) -> Vec<u32>
pub fn query(&self, vector: &[f32], timestamp: i64) -> Vec<u32>
Query: find candidate node IDs under spatiotemporal locality.
Returns deduplicated candidate IDs from all tables + multi-probe.
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
Memory usage estimate in bytes.
Sourcefn compute_hash(&self, table_idx: usize, vector: &[f32], timestamp: i64) -> u64
fn compute_hash(&self, table_idx: usize, vector: &[f32], timestamp: i64) -> u64
Compute the full hash for a point in a specific table.
Sourcefn semantic_hash(&self, table_idx: usize, vector: &[f32]) -> Vec<bool>
fn semantic_hash(&self, table_idx: usize, vector: &[f32]) -> Vec<bool>
Compute semantic hash bits via random hyperplane LSH.
Sourcefn temporal_bucket(&self, timestamp: i64) -> i64
fn temporal_bucket(&self, timestamp: i64) -> i64
Compute temporal bucket index.
Auto Trait Implementations§
impl Freeze for TemporalLSH
impl RefUnwindSafe for TemporalLSH
impl Send for TemporalLSH
impl Sync for TemporalLSH
impl Unpin for TemporalLSH
impl UnwindSafe for TemporalLSH
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