mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 17:14:59 +08: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>
|
impl<'c, S, FI> QueryBuilder<'c, S, FI>
|
||||||
where S: 'static + Store + Send + Clone,
|
where S: Store + Sync,
|
||||||
S::Error: Send,
|
S::Error: Send,
|
||||||
{
|
{
|
||||||
fn query_all(&self, query: &str) -> Result<Vec<RawDocument>, S::Error> {
|
fn query_all(&self, query: &str) -> Result<Vec<RawDocument>, S::Error> {
|
||||||
let (automatons, query_enhancer) = generate_automatons(query, &self.store)?;
|
let (automatons, query_enhancer) = generate_automatons(query, &self.store)?;
|
||||||
let searchables = self.searchable_attrs.clone();
|
let searchables = self.searchable_attrs.as_ref();
|
||||||
let store = self.store.clone();
|
let store = &self.store;
|
||||||
|
|
||||||
|
rayon::scope(move |s| {
|
||||||
|
enum Error<E> {
|
||||||
|
SendError,
|
||||||
|
StoreError(E),
|
||||||
|
}
|
||||||
|
|
||||||
let mut matches = Vec::new();
|
let mut matches = Vec::new();
|
||||||
let mut highlights = Vec::new();
|
let mut highlights = Vec::new();
|
||||||
@ -332,16 +338,11 @@ where S: 'static + Store + Send + Clone,
|
|||||||
|
|
||||||
let (sender, receiver) = crossbeam_channel::bounded(10);
|
let (sender, receiver) = crossbeam_channel::bounded(10);
|
||||||
|
|
||||||
rayon::spawn(move || {
|
s.spawn(move |_| {
|
||||||
enum Error<E> {
|
|
||||||
SendError,
|
|
||||||
StoreError(E),
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = automatons
|
let result = automatons
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.par_bridge()
|
.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 (sender, store, searchables) = data;
|
||||||
let Automaton { index, is_exact, query_len, dfa, .. } = automaton;
|
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());
|
info!("{} total documents to classify", raw_documents.len());
|
||||||
|
|
||||||
Ok(raw_documents)
|
Ok(raw_documents)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'c, S, FI> QueryBuilder<'c, S, FI>
|
impl<'c, S, FI> QueryBuilder<'c, S, FI>
|
||||||
where S: 'static + Store + Send + Clone,
|
where S: Store + Sync,
|
||||||
S::Error: Send,
|
S::Error: Send,
|
||||||
FI: Fn(DocumentId) -> bool,
|
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>
|
impl<'c, S, FI, FD, K> DistinctQueryBuilder<'c, S, FI, FD>
|
||||||
where S: 'static + Store + Send + Clone,
|
where S: Store + Sync,
|
||||||
S::Error: Send,
|
S::Error: Send,
|
||||||
FI: Fn(DocumentId) -> bool,
|
FI: Fn(DocumentId) -> bool,
|
||||||
FD: Fn(DocumentId) -> Option<K>,
|
FD: Fn(DocumentId) -> Option<K>,
|
||||||
|
Loading…
Reference in New Issue
Block a user