pub struct SparseIndex { /* private fields */ }Expand description
Inverted index over weighted sparse vectors, keyed by token id.
Implementations§
Source§impl SparseIndex
impl SparseIndex
pub fn new() -> Self
Sourcepub fn insert(&mut self, terms: &[(u32, f32)], row_id: RowId)
pub fn insert(&mut self, terms: &[(u32, f32)], row_id: RowId)
Insert a document’s sparse vector (terms need not be sorted; duplicate
tokens within one doc accumulate).
Sourcepub fn search(&self, query: &[(u32, f32)], k: usize) -> Vec<(RowId, f32)>
pub fn search(&self, query: &[(u32, f32)], k: usize) -> Vec<(RowId, f32)>
Top-k row ids by sparse dot product with query (highest score first).
pub fn is_empty(&self) -> bool
Sourcepub fn entries(&self) -> Vec<(u32, Vec<(RowId, f32)>)>
pub fn entries(&self) -> Vec<(u32, Vec<(RowId, f32)>)>
Snapshot the inverted lists for checkpointing to _idx/global.idx.
Sourcepub fn from_entries(entries: Vec<(u32, Vec<(RowId, f32)>)>) -> Self
pub fn from_entries(entries: Vec<(u32, Vec<(RowId, f32)>)>) -> Self
Rebuild from a snapshot produced by SparseIndex::entries.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SparseIndex
impl RefUnwindSafe for SparseIndex
impl Send for SparseIndex
impl Sync for SparseIndex
impl Unpin for SparseIndex
impl UnsafeUnpin for SparseIndex
impl UnwindSafe for SparseIndex
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> 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