Try with an exponential search

This commit is contained in:
Clément Renault 2020-01-14 16:52:24 +01:00
parent 40dab80dfa
commit 6edb460bea
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -15,7 +15,7 @@ use levenshtein_automata::DFA;
use log::debug; use log::debug;
use meilisearch_tokenizer::{is_cjk, split_query_string}; use meilisearch_tokenizer::{is_cjk, split_query_string};
use meilisearch_types::DocIndex; use meilisearch_types::DocIndex;
use sdset::{Set, SetBuf}; use sdset::{Set, SetBuf, exponential_search};
use slice_group_by::{GroupBy, GroupByMut}; use slice_group_by::{GroupBy, GroupByMut};
use crate::automaton::NGRAMS; use crate::automaton::NGRAMS;
@ -103,7 +103,7 @@ where
let mut offset = 0; let mut offset = 0;
for id in docids.as_slice() { for id in docids.as_slice() {
let di = DocIndex { document_id: *id, ..DocIndex::default() }; let di = DocIndex { document_id: *id, ..DocIndex::default() };
let pos = postings_list_view[offset..].binary_search(&di).unwrap_or_else(|x| x); let pos = exponential_search(&postings_list_view[offset..], &di).unwrap_or_else(|x| x);
let group = postings_list_view[offset + pos..] let group = postings_list_view[offset + pos..]
.linear_group_by_key(|m| m.document_id) .linear_group_by_key(|m| m.document_id)