pub struct Index { /* private fields */ }Expand description
An eCP index opened from disk. Nodes are read on first visit and cached in memory, along with open queries. Safe to share across threads; a search and an insert only wait for each other on the same leaf.
Implementations§
Source§impl Index
impl Index
Sourcepub fn new_search(
&self,
query: Array1<f32>,
k: usize,
search_exp: u32,
max_increments: i32,
exclude: &HashSet<u32>,
) -> Result<(Vec<(NotNan<f32>, u32)>, usize)>
pub fn new_search( &self, query: Array1<f32>, k: usize, search_exp: u32, max_increments: i32, exclude: &HashSet<u32>, ) -> Result<(Vec<(NotNan<f32>, u32)>, usize)>
Searches for query and returns the k best items as (score, item_id) pairs, lowest
score first (L2 distance, or negated inner product for IP), plus the query id. The query
keeps exclude and never returns those ids. Other arguments: Self::incremental_search.
Sourcepub fn incremental_search(
&self,
query_id: usize,
k: usize,
search_exp: u32,
max_increments: i32,
) -> Result<u32>
pub fn incremental_search( &self, query_id: usize, k: usize, search_exp: u32, max_increments: i32, ) -> Result<u32>
Scores search_exp more leaves for query query_id, buffering their items
except the query’s excluded ids. If fewer than k items are buffered by then, it
doubles search_exp and goes on, at most max_increments times (-1 for no limit).
Returns how many leaves this call visited.
Sourcepub fn get_next_k_items(
&self,
query_id: usize,
k: usize,
search_exp: u32,
max_increments: i32,
exclude: &HashSet<u32>,
) -> Result<Vec<(NotNan<f32>, u32)>>
pub fn get_next_k_items( &self, query_id: usize, k: usize, search_exp: u32, max_increments: i32, exclude: &HashSet<u32>, ) -> Result<Vec<(NotNan<f32>, u32)>>
Adds exclude to query query_id’s exclude set, then returns its next k items,
searching further first if fewer are buffered; empty for an unknown query_id or after
shutdown. Other arguments: Self::incremental_search.
Source§impl Index
impl Index
Sourcepub fn load(
index_path: PathBuf,
memory_limit_bytes: Option<usize>,
) -> Result<Self>
pub fn load( index_path: PathBuf, memory_limit_bytes: Option<usize>, ) -> Result<Self>
Opens the index at index_path, reading its info/* fields and
root. Other nodes load on first visit. memory_limit_bytes caps the
node and query data kept in memory; None means no cap.
Sourcepub fn set_memory_limit_bytes(&mut self, memory_limit_bytes: Option<usize>)
pub fn set_memory_limit_bytes(&mut self, memory_limit_bytes: Option<usize>)
Changes the memory limit without reloading; None removes the cap.
It rebuilds both caches, so it suits occasional reconfiguration, not
a call per query.
Sourcepub fn shutdown(&self) -> Result<()>
pub fn shutdown(&self) -> Result<()>
Stops new searches and saves every open query to disk, so a later
Index can resume it; a query with nothing left to return is erased
instead. Safe to call more than once. Err if any query fails to save.
Sourcepub fn cleanup_persisted_queries_older_than(
&self,
cutoff_unix_secs: u64,
) -> Result<usize>
pub fn cleanup_persisted_queries_older_than( &self, cutoff_unix_secs: u64, ) -> Result<usize>
Erases every query saved to disk before cutoff_unix_secs (seconds
since the Unix epoch). Returns how many were erased.
Auto Trait Implementations§
impl !Freeze for Index
impl !RefUnwindSafe for Index
impl !UnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnsafeUnpin for Index
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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