pub trait Search: AsyncFriendly {
type Id: Id;
type Parameters: Clone + AsyncFriendly;
type Output: AsyncFriendly;
// Required methods
fn num_queries(&self) -> usize;
fn id_count(&self, parameters: &Self::Parameters) -> IdCount;
fn search<O>(
&self,
parameters: &Self::Parameters,
buffer: &mut O,
index: usize,
) -> impl Future<Output = ANNResult<Self::Output>> + Send
where O: SearchOutputBuffer<Self::Id> + Send;
}Expand description
The core search API for approximate nearest neighbor searches.
This uses a model where queries are stored internally and identified by their
index. Queries are numbered from 0 to N-1 where N = Search::num_queries()
is the total number of queries.
This trait is used in conjunction with search and search_all. See the
documentation of those methods for more details.
Required Associated Types§
Sourcetype Id: Id
type Id: Id
The identifier for the type returned by search. These are canonically the unique IDs associated with indexed vectors.
Sourcetype Parameters: Clone + AsyncFriendly
type Parameters: Clone + AsyncFriendly
Custom input search parameters.
Sourcetype Output: AsyncFriendly
type Output: AsyncFriendly
Custom output parameters. This augments the standard metrics collected by
search and allows implementation-specific data to be returned.
Required Methods§
Sourcefn num_queries(&self) -> usize
fn num_queries(&self) -> usize
The number of queries that can be searched. The machinery in search and
search_all will invoke Search::search for each index in 0..N where
N is the returned value of this method.
Sourcefn id_count(&self, parameters: &Self::Parameters) -> IdCount
fn id_count(&self, parameters: &Self::Parameters) -> IdCount
Provide a hint for the number of IDs returned for each query. This is used to optimize internal buffer allocations.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.