pub struct SpFreshIndex { /* private fields */ }Expand description
SPFresh Index implementation
Implementations§
Source§impl SpFreshIndex
impl SpFreshIndex
Sourcepub fn new(config: SpFreshConfig) -> Self
pub fn new(config: SpFreshConfig) -> Self
Create a new SPFresh index
Sourcepub fn is_trained(&self) -> bool
pub fn is_trained(&self) -> bool
Check if index is trained
Sourcepub fn train(&self, vectors: &[Vector]) -> Result<(), String>
pub fn train(&self, vectors: &[Vector]) -> Result<(), String>
Train the index with initial vectors using k-means
Sourcepub fn add(&self, vectors: Vec<Vector>) -> Result<usize, String>
pub fn add(&self, vectors: Vec<Vector>) -> Result<usize, String>
Add vectors to the index (LIRE: lazy insertion)
Sourcepub fn search(
&self,
query: &[f32],
k: usize,
) -> Result<Vec<SpFreshSearchResult>, String>
pub fn search( &self, query: &[f32], k: usize, ) -> Result<Vec<SpFreshSearchResult>, String>
Search for nearest neighbors
Sourcepub fn merge_small_clusters(&self) -> usize
pub fn merge_small_clusters(&self) -> usize
Merge small clusters
Sourcepub fn stats(&self) -> SpFreshStats
pub fn stats(&self) -> SpFreshStats
Get index statistics
Sourcepub fn config(&self) -> &SpFreshConfig
pub fn config(&self) -> &SpFreshConfig
Get configuration
Sourcepub fn from_snapshot(snapshot: SpFreshFullSnapshot) -> Result<Self, String>
pub fn from_snapshot(snapshot: SpFreshFullSnapshot) -> Result<Self, String>
Restore SPFresh index from a full snapshot
Trait Implementations§
Source§impl Persistable for SpFreshIndex
impl Persistable for SpFreshIndex
Source§type Snapshot = SpFreshFullSnapshot
type Snapshot = SpFreshFullSnapshot
The snapshot type for this index
Source§fn to_snapshot(&self) -> SpFreshFullSnapshot
fn to_snapshot(&self) -> SpFreshFullSnapshot
Create a snapshot of the current state
Source§fn from_snapshot(snapshot: SpFreshFullSnapshot) -> Result<Self, String>
fn from_snapshot(snapshot: SpFreshFullSnapshot) -> Result<Self, String>
Restore from a snapshot
Auto Trait Implementations§
impl !Freeze for SpFreshIndex
impl !RefUnwindSafe for SpFreshIndex
impl Send for SpFreshIndex
impl Sync for SpFreshIndex
impl Unpin for SpFreshIndex
impl UnsafeUnpin for SpFreshIndex
impl UnwindSafe for SpFreshIndex
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