Struct TemporalLSH

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

Configuration.

§dim: usize

Dimensionality of vectors.

§n_points: usize

Total number of indexed points.

Implementations§

Source§

impl TemporalLSH

Source

pub fn new(dim: usize, config: TLSHConfig) -> Self

Create a new empty T-LSH index.

Source

pub fn build(vectors: &[&[f32]], timestamps: &[i64], config: TLSHConfig) -> Self

Build T-LSH from existing index data.

Source

pub fn insert(&mut self, node_id: u32, vector: &[f32], timestamp: i64)

Insert a point into all hash tables.

Source

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.

Source

pub fn len(&self) -> usize

Number of indexed points.

Source

pub fn is_empty(&self) -> bool

Whether the index is empty.

Source

pub fn memory_bytes(&self) -> usize

Memory usage estimate in bytes.

Source

fn compute_hash(&self, table_idx: usize, vector: &[f32], timestamp: i64) -> u64

Compute the full hash for a point in a specific table.

Source

fn semantic_hash(&self, table_idx: usize, vector: &[f32]) -> Vec<bool>

Compute semantic hash bits via random hyperplane LSH.

Source

fn temporal_bucket(&self, timestamp: i64) -> i64

Compute temporal bucket index.

Source

fn combine_hash( &self, _table_idx: usize, sem_bits: &[bool], temp_bucket: i64, ) -> u64

Combine semantic bits and temporal bucket into a single u64 hash.

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