Fixes after rebase to fix new issues.

This commit is contained in:
Ewan Higgs 2022-10-25 20:58:31 +02:00
parent 17f7922bfc
commit 2ce025a906
5 changed files with 21 additions and 26 deletions

View File

@ -200,7 +200,7 @@ impl Index {
pub fn new<P: AsRef<Path>>(options: heed::EnvOpenOptions, path: P) -> Result<Index> { pub fn new<P: AsRef<Path>>(options: heed::EnvOpenOptions, path: P) -> Result<Index> {
let now = OffsetDateTime::now_utc(); let now = OffsetDateTime::now_utc();
Self::new_with_creation_dates(options, path, now.clone(), now) Self::new_with_creation_dates(options, path, now, now)
} }
fn set_creation_dates( fn set_creation_dates(

View File

@ -562,11 +562,11 @@ fn query_pair_proximity_docids(
)? { )? {
Some(docids) => Ok(docids), Some(docids) => Ok(docids),
None => { None => {
let r_words = word_derivations(&right, true, 0, ctx.words_fst(), wdcache)?; let r_words = word_derivations(right, true, 0, ctx.words_fst(), wdcache)?;
all_word_pair_overall_proximity_docids( all_word_pair_overall_proximity_docids(
ctx, ctx,
&[(left, 0)], &[(left, 0)],
&r_words, r_words,
proximity, proximity,
) )
} }
@ -592,11 +592,11 @@ fn query_pair_proximity_docids(
Some(docids) => Ok(docids), Some(docids) => Ok(docids),
None => { None => {
let r_words = let r_words =
word_derivations(&right, true, 0, ctx.words_fst(), wdcache)?; word_derivations(right, true, 0, ctx.words_fst(), wdcache)?;
all_word_pair_overall_proximity_docids( all_word_pair_overall_proximity_docids(
ctx, ctx,
&[(left, 0)], &[(left, 0)],
&r_words, r_words,
proximity, proximity,
) )
} }
@ -609,17 +609,17 @@ fn query_pair_proximity_docids(
} }
} }
(QueryKind::Exact { word: left, .. }, QueryKind::Tolerant { typo, word: right }) => { (QueryKind::Exact { word: left, .. }, QueryKind::Tolerant { typo, word: right }) => {
let r_words = word_derivations(&right, prefix, *typo, ctx.words_fst(), wdcache)?; let r_words = word_derivations(right, prefix, *typo, ctx.words_fst(), wdcache)?;
all_word_pair_overall_proximity_docids(ctx, &[(left, 0)], &r_words, proximity) all_word_pair_overall_proximity_docids(ctx, &[(left, 0)], r_words, proximity)
} }
( (
QueryKind::Tolerant { typo: l_typo, word: left }, QueryKind::Tolerant { typo: l_typo, word: left },
QueryKind::Tolerant { typo: r_typo, word: right }, QueryKind::Tolerant { typo: r_typo, word: right },
) => { ) => {
let l_words = let l_words =
word_derivations(&left, false, *l_typo, ctx.words_fst(), wdcache)?.to_owned(); word_derivations(left, false, *l_typo, ctx.words_fst(), wdcache)?.to_owned();
let r_words = word_derivations(&right, prefix, *r_typo, ctx.words_fst(), wdcache)?; let r_words = word_derivations(right, prefix, *r_typo, ctx.words_fst(), wdcache)?;
all_word_pair_overall_proximity_docids(ctx, &l_words, &r_words, proximity) all_word_pair_overall_proximity_docids(ctx, &l_words, r_words, proximity)
} }
} }
} }

View File

@ -332,8 +332,8 @@ fn compute_facet_number_levels(
/// 1. a vector of grenad::Reader. The reader at index `i` corresponds to the elements of level `i + 1` /// 1. a vector of grenad::Reader. The reader at index `i` corresponds to the elements of level `i + 1`
/// that must be inserted into the database. /// that must be inserted into the database.
/// 2. a roaring bitmap of all the document ids present in the database /// 2. a roaring bitmap of all the document ids present in the database
fn compute_facet_strings_levels<'t>( fn compute_facet_strings_levels(
rtxn: &'t heed::RoTxn, rtxn: &heed::RoTxn,
db: heed::Database<FacetStringLevelZeroCodec, FacetStringLevelZeroValueCodec>, db: heed::Database<FacetStringLevelZeroCodec, FacetStringLevelZeroValueCodec>,
compression_type: CompressionType, compression_type: CompressionType,
compression_level: Option<u32>, compression_level: Option<u32>,

View File

@ -30,9 +30,8 @@ pub fn index_prefix_word_database(
debug!("Computing and writing the word prefix pair proximity docids into LMDB on disk..."); debug!("Computing and writing the word prefix pair proximity docids into LMDB on disk...");
let common_prefixes: Vec<_> = common_prefix_fst_words let common_prefixes: Vec<_> = common_prefix_fst_words
.into_iter() .iter()
.map(|s| s.into_iter()) .flat_map(|s| s.iter())
.flatten()
.map(|s| s.as_str()) .map(|s| s.as_str())
.filter(|s| s.len() <= max_prefix_length) .filter(|s| s.len() <= max_prefix_length)
.collect(); .collect();
@ -73,7 +72,7 @@ pub fn index_prefix_word_database(
// Now we do the same thing with the new prefixes and all word pairs in the DB // Now we do the same thing with the new prefixes and all word pairs in the DB
let new_prefixes: Vec<_> = new_prefix_fst_words let new_prefixes: Vec<_> = new_prefix_fst_words
.into_iter() .iter()
.map(|s| s.as_str()) .map(|s| s.as_str())
.filter(|s| s.len() <= max_prefix_length) .filter(|s| s.len() <= max_prefix_length)
.collect(); .collect();

View File

@ -195,9 +195,8 @@ pub fn index_word_prefix_database(
// Make a prefix trie from the common prefixes that are shorter than self.max_prefix_length // Make a prefix trie from the common prefixes that are shorter than self.max_prefix_length
let prefixes = PrefixTrieNode::from_sorted_prefixes( let prefixes = PrefixTrieNode::from_sorted_prefixes(
common_prefix_fst_words common_prefix_fst_words
.into_iter() .iter()
.map(|s| s.into_iter()) .flat_map(|s| s.iter())
.flatten()
.map(|s| s.as_str()) .map(|s| s.as_str())
.filter(|s| s.len() <= max_prefix_length), .filter(|s| s.len() <= max_prefix_length),
); );
@ -237,10 +236,7 @@ pub fn index_word_prefix_database(
// Now we do the same thing with the new prefixes and all word pairs in the DB // Now we do the same thing with the new prefixes and all word pairs in the DB
let prefixes = PrefixTrieNode::from_sorted_prefixes( let prefixes = PrefixTrieNode::from_sorted_prefixes(
new_prefix_fst_words new_prefix_fst_words.iter().map(|s| s.as_str()).filter(|s| s.len() <= max_prefix_length),
.into_iter()
.map(|s| s.as_str())
.filter(|s| s.len() <= max_prefix_length),
); );
if !prefixes.is_empty() { if !prefixes.is_empty() {
@ -366,7 +362,7 @@ fn execute_on_word_pairs_and_prefixes<I>(
&mut prefix_buffer, &mut prefix_buffer,
&prefix_search_start, &prefix_search_start,
|prefix_buffer| { |prefix_buffer| {
batch.insert(&prefix_buffer, data.to_vec()); batch.insert(prefix_buffer, data.to_vec());
}, },
); );
} }
@ -484,7 +480,7 @@ impl PrefixTrieNode {
fn set_search_start(&self, word: &[u8], search_start: &mut PrefixTrieNodeSearchStart) -> bool { fn set_search_start(&self, word: &[u8], search_start: &mut PrefixTrieNodeSearchStart) -> bool {
let byte = word[0]; let byte = word[0];
if self.children[search_start.0].1 == byte { if self.children[search_start.0].1 == byte {
return true; true
} else { } else {
match self.children[search_start.0..].binary_search_by_key(&byte, |x| x.1) { match self.children[search_start.0..].binary_search_by_key(&byte, |x| x.1) {
Ok(position) => { Ok(position) => {
@ -502,7 +498,7 @@ impl PrefixTrieNode {
fn from_sorted_prefixes<'a>(prefixes: impl Iterator<Item = &'a str>) -> Self { fn from_sorted_prefixes<'a>(prefixes: impl Iterator<Item = &'a str>) -> Self {
let mut node = PrefixTrieNode::default(); let mut node = PrefixTrieNode::default();
for prefix in prefixes { for prefix in prefixes {
node.insert_sorted_prefix(prefix.as_bytes().into_iter()); node.insert_sorted_prefix(prefix.as_bytes().iter());
} }
node node
} }