Skip to main content

Hnsw

Struct Hnsw 

Source
pub struct Hnsw { /* private fields */ }
Expand description

One shard’s ANN graph for one index.

Implementations§

Source§

impl Hnsw

Source

pub fn new(dim: usize, params: HnswParams) -> Self

Empty graph for dim-dimensional vectors.

Source

pub fn dim(&self) -> usize

Declared dimensionality.

Source

pub fn apply(&mut self, key: &[u8], vector: Option<Vec<f32>>)

Insert or replace key’s vector (None = remove). Replace = tombstone old + insert new (RFC D5).

Source

pub fn knn(&self, query: &[f32], k: usize, ef: usize) -> Vec<(Vec<u8>, f32)>

k nearest LIVING vectors to query (raw form; prepared here). ef = query beam width (0 → the max(4k, 100) default); larger beams trade latency for recall — the canonical HNSW knob.

Source

pub fn contains(&self, key: &[u8]) -> bool

Membership (living only).

Source

pub fn stats(&self) -> VectorStats

Counters (RFC D6).

Source

pub fn rebuild(&mut self)

Bounded rebuild: re-insert every living vector into a fresh graph (drops tombstones and their edges) — RFC D5.

Auto Trait Implementations§

§

impl Freeze for Hnsw

§

impl RefUnwindSafe for Hnsw

§

impl Send for Hnsw

§

impl Sync for Hnsw

§

impl Unpin for Hnsw

§

impl UnsafeUnpin for Hnsw

§

impl UnwindSafe for Hnsw

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