pub struct MultiHop<DP, T, S>where
DP: DataProvider,{ /* private fields */ }Expand description
A built-in helper for benchmarking filtered K-nearest neighbors search using the multi-hop search method.
This is intended to be used in conjunction with search::search or search::search_all
and provides some basic additional metrics for the latter. Result aggregation for
search::search_all is provided by the search::graph::knn::Aggregator type (same
aggregator as search::graph::knn::KNN).
The provided implementation of Search accepts graph::search::Knn
and returns search::graph::knn::Metrics as additional output.
Implementations§
Source§impl<DP, T, S> MultiHop<DP, T, S>where
DP: DataProvider,
impl<DP, T, S> MultiHop<DP, T, S>where
DP: DataProvider,
Sourcepub fn new(
index: Arc<DiskANNIndex<DP>>,
queries: Arc<Matrix<T>>,
strategy: Strategy<S>,
labels: Arc<[Arc<dyn QueryLabelProvider<DP::InternalId>>]>,
) -> Result<Arc<Self>>
pub fn new( index: Arc<DiskANNIndex<DP>>, queries: Arc<Matrix<T>>, strategy: Strategy<S>, labels: Arc<[Arc<dyn QueryLabelProvider<DP::InternalId>>]>, ) -> Result<Arc<Self>>
Construct a new MultiHop searcher.
If strategy is one of the container variants of Strategy, its length
must match the number of rows in queries. If this is the case, then the
strategies will have a querywise correspondence (see search::SearchResults)
with the query matrix.
Additionally, the length of labels must match the number of rows in queries
and will be used in querywise correspondence with queries.
§Errors
Returns an error under the following conditions.
-
The number of elements in
strategyis not compatible with the number of rows inqueries. -
The number of label providers in
labelsis not equal to the number of rows inqueries.
Trait Implementations§
Source§impl<DP, T, S> Search for MultiHop<DP, T, S>where
DP: DataProvider<Context: Default, ExternalId: Id>,
S: for<'a> DefaultSearchStrategy<DP, &'a [T], DP::ExternalId> + Clone + AsyncFriendly,
T: AsyncFriendly + Clone,
impl<DP, T, S> Search for MultiHop<DP, T, S>where
DP: DataProvider<Context: Default, ExternalId: Id>,
S: for<'a> DefaultSearchStrategy<DP, &'a [T], DP::ExternalId> + Clone + AsyncFriendly,
T: AsyncFriendly + Clone,
Source§type Id = <DP as DataProvider>::ExternalId
type Id = <DP as DataProvider>::ExternalId
Source§type Parameters = Knn
type Parameters = Knn
Source§type Output = Metrics
type Output = Metrics
search and allows implementation-specific data to be returned.Source§fn num_queries(&self) -> usize
fn num_queries(&self) -> usize
search and
search_all will invoke Search::search for each index in 0..N where
N is the returned value of this method.Source§fn id_count(&self, parameters: &Self::Parameters) -> IdCount
fn id_count(&self, parameters: &Self::Parameters) -> IdCount
Auto Trait Implementations§
impl<DP, T, S> Freeze for MultiHop<DP, T, S>where
S: Freeze,
impl<DP, T, S> !RefUnwindSafe for MultiHop<DP, T, S>
impl<DP, T, S> Send for MultiHop<DP, T, S>
impl<DP, T, S> Sync for MultiHop<DP, T, S>
impl<DP, T, S> Unpin for MultiHop<DP, T, S>where
S: Unpin,
impl<DP, T, S> UnsafeUnpin for MultiHop<DP, T, S>where
S: UnsafeUnpin,
impl<DP, T, S> !UnwindSafe for MultiHop<DP, T, S>
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
Source§impl<T> DispatchRule<T> for T
impl<T> DispatchRule<T> for T
Source§type Error = Infallible
type Error = Infallible
convert.Source§fn try_match(_from: &T) -> Result<MatchScore, FailureScore>
fn try_match(_from: &T) -> Result<MatchScore, FailureScore>
Source§fn convert(from: T) -> Result<T, <T as DispatchRule<T>>::Error>
fn convert(from: T) -> Result<T, <T as DispatchRule<T>>::Error>
Source§fn description(f: &mut Formatter<'_>, from: Option<&T>) -> Result<(), Error>
fn description(f: &mut Formatter<'_>, from: Option<&T>) -> Result<(), Error>
Source§fn try_match_verbose<'a>(
from: &'a From,
) -> Result<MatchScore, TaggedFailureScore<'a>>where
Self: 'a,
fn try_match_verbose<'a>(
from: &'a From,
) -> Result<MatchScore, TaggedFailureScore<'a>>where
Self: 'a,
try_match but returns a reason for a failed score. Read more