pub struct HnswIndex { /* private fields */ }Expand description
HNSW Index for approximate nearest neighbor search
Implementations§
Source§impl HnswIndex
impl HnswIndex
Sourcepub fn with_config(config: HnswConfig) -> Self
pub fn with_config(config: HnswConfig) -> Self
Create a new HNSW index with custom configuration
Sourcepub fn search(&self, query: &[f32], k: usize) -> Vec<(VectorId, f32)>
pub fn search(&self, query: &[f32], k: usize) -> Vec<(VectorId, f32)>
Search for k nearest neighbors
Sourcepub fn search_with_ef(
&self,
query: &[f32],
k: usize,
ef: usize,
) -> Vec<(VectorId, f32)>
pub fn search_with_ef( &self, query: &[f32], k: usize, ef: usize, ) -> Vec<(VectorId, f32)>
Search with custom ef parameter
Sourcepub fn config(&self) -> &HnswConfig
pub fn config(&self) -> &HnswConfig
Get configuration
Sourcepub fn entry_point(&self) -> Option<usize>
pub fn entry_point(&self) -> Option<usize>
Get entry point node index
Sourcepub fn from_snapshot(snapshot: HnswFullSnapshot) -> Result<Self, String>
pub fn from_snapshot(snapshot: HnswFullSnapshot) -> Result<Self, String>
Restore HNSW index from a full snapshot
Trait Implementations§
Source§impl Persistable for HnswIndex
impl Persistable for HnswIndex
Source§type Snapshot = HnswFullSnapshot
type Snapshot = HnswFullSnapshot
The snapshot type for this index
Source§fn to_snapshot(&self) -> HnswFullSnapshot
fn to_snapshot(&self) -> HnswFullSnapshot
Create a snapshot of the current state
Source§fn from_snapshot(snapshot: HnswFullSnapshot) -> Result<Self, String>
fn from_snapshot(snapshot: HnswFullSnapshot) -> Result<Self, String>
Restore from a snapshot
Auto Trait Implementations§
impl !Freeze for HnswIndex
impl !RefUnwindSafe for HnswIndex
impl Send for HnswIndex
impl Sync for HnswIndex
impl Unpin for HnswIndex
impl UnsafeUnpin for HnswIndex
impl UnwindSafe for HnswIndex
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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