mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 13:24:27 +01:00
feat: Try to simplify Store trait bound with a rayon scope
This commit is contained in:
parent
b7b60b5fe5
commit
0ee56314fb
@ -316,13 +316,19 @@ fn multiword_rewrite_matches(
|
||||
}
|
||||
|
||||
impl<'c, S, FI> QueryBuilder<'c, S, FI>
|
||||
where S: 'static + Store + Send + Clone,
|
||||
where S: Store + Sync,
|
||||
S::Error: Send,
|
||||
{
|
||||
fn query_all(&self, query: &str) -> Result<Vec<RawDocument>, S::Error> {
|
||||
let (automatons, query_enhancer) = generate_automatons(query, &self.store)?;
|
||||
let searchables = self.searchable_attrs.clone();
|
||||
let store = self.store.clone();
|
||||
let searchables = self.searchable_attrs.as_ref();
|
||||
let store = &self.store;
|
||||
|
||||
rayon::scope(move |s| {
|
||||
enum Error<E> {
|
||||
SendError,
|
||||
StoreError(E),
|
||||
}
|
||||
|
||||
let mut matches = Vec::new();
|
||||
let mut highlights = Vec::new();
|
||||
@ -332,16 +338,11 @@ where S: 'static + Store + Send + Clone,
|
||||
|
||||
let (sender, receiver) = crossbeam_channel::bounded(10);
|
||||
|
||||
rayon::spawn(move || {
|
||||
enum Error<E> {
|
||||
SendError,
|
||||
StoreError(E),
|
||||
}
|
||||
|
||||
s.spawn(move |_| {
|
||||
let result = automatons
|
||||
.into_iter()
|
||||
.par_bridge()
|
||||
.try_for_each_with((sender, store, searchables.as_ref()), |data, automaton| {
|
||||
.try_for_each_with((sender, store, searchables), |data, automaton| {
|
||||
let (sender, store, searchables) = data;
|
||||
let Automaton { index, is_exact, query_len, dfa, .. } = automaton;
|
||||
|
||||
@ -433,11 +434,12 @@ where S: 'static + Store + Send + Clone,
|
||||
info!("{} total documents to classify", raw_documents.len());
|
||||
|
||||
Ok(raw_documents)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c, S, FI> QueryBuilder<'c, S, FI>
|
||||
where S: 'static + Store + Send + Clone,
|
||||
where S: Store + Sync,
|
||||
S::Error: Send,
|
||||
FI: Fn(DocumentId) -> bool,
|
||||
{
|
||||
@ -515,7 +517,7 @@ impl<'c, I, FI, FD> DistinctQueryBuilder<'c, I, FI, FD>
|
||||
}
|
||||
|
||||
impl<'c, S, FI, FD, K> DistinctQueryBuilder<'c, S, FI, FD>
|
||||
where S: 'static + Store + Send + Clone,
|
||||
where S: Store + Sync,
|
||||
S::Error: Send,
|
||||
FI: Fn(DocumentId) -> bool,
|
||||
FD: Fn(DocumentId) -> Option<K>,
|
||||
|
Loading…
Reference in New Issue
Block a user