diff --git a/milli/src/search/new/db_cache.rs b/milli/src/search/new/db_cache.rs index c32c7ba79..ad843b045 100644 --- a/milli/src/search/new/db_cache.rs +++ b/milli/src/search/new/db_cache.rs @@ -9,6 +9,7 @@ use roaring::RoaringBitmap; use super::interner::Interned; use super::Word; +use crate::heed_codec::StrBEU16Codec; use crate::{ CboRoaringBitmapCodec, CboRoaringBitmapLenCodec, Result, RoaringBitmapCodec, SearchContext, }; @@ -292,14 +293,16 @@ impl<'ctx> SearchContext<'ctx> { &mut self, word_prefix: Interned, fid: u16, - ) -> Result> { + ) -> Result> { DatabaseCache::get_value( self.txn, (word_prefix, fid), &(self.word_interner.get(word_prefix).as_str(), fid), &mut self.db_cache.word_prefix_fid_docids, self.index.word_prefix_fid_docids.remap_data_type::(), - ) + )? + .map(|bytes| CboRoaringBitmapCodec::bytes_decode(bytes).ok_or(heed::Error::Decoding.into())) + .transpose() } pub fn get_db_word_fids(&mut self, word: Interned) -> Result> { diff --git a/milli/src/search/new/ranking_rule_graph/attribute/mod.rs b/milli/src/search/new/ranking_rule_graph/attribute/mod.rs index 4ca0b7dc4..80c1f4c6a 100644 --- a/milli/src/search/new/ranking_rule_graph/attribute/mod.rs +++ b/milli/src/search/new/ranking_rule_graph/attribute/mod.rs @@ -4,9 +4,7 @@ use roaring::RoaringBitmap; use super::{ComputedCondition, RankingRuleGraphTrait}; use crate::search::new::interner::{DedupInterner, Interned}; use crate::search::new::query_term::LocatedQueryTermSubset; -use crate::search::new::resolve_query_graph::{ - compute_query_term_subset_docids, compute_query_term_subset_docids_within_field_id, -}; +use crate::search::new::resolve_query_graph::compute_query_term_subset_docids_within_field_id; use crate::search::new::SearchContext; use crate::Result; @@ -53,7 +51,7 @@ impl RankingRuleGraphTrait for AttributeGraph { let mut all_fields = FxHashSet::default(); for word in term.term_subset.all_single_words_except_prefix_db(ctx)? { - let fields = ctx.get_db_word_fids(word)?; + let fields = ctx.get_db_word_fids(word.interned())?; all_fields.extend(fields); } @@ -65,7 +63,7 @@ impl RankingRuleGraphTrait for AttributeGraph { } if let Some(word_prefix) = term.term_subset.use_prefix_db(ctx) { - let fields = ctx.get_db_word_prefix_fids(word_prefix)?; + let fields = ctx.get_db_word_prefix_fids(word_prefix.interned())?; all_fields.extend(fields); } diff --git a/milli/src/search/new/resolve_query_graph.rs b/milli/src/search/new/resolve_query_graph.rs index 711497009..a125caa39 100644 --- a/milli/src/search/new/resolve_query_graph.rs +++ b/milli/src/search/new/resolve_query_graph.rs @@ -63,25 +63,24 @@ pub fn compute_query_term_subset_docids_within_field_id( let mut docids = RoaringBitmap::new(); for word in term.all_single_words_except_prefix_db(ctx)? { - if let Some(word_fid_docids) = ctx.get_db_word_fid_docids(word, fid)? { - docids |= CboRoaringBitmapCodec::bytes_decode(word_fid_docids) - .ok_or(heed::Error::Decoding)?; + if let Some(word_fid_docids) = ctx.get_db_word_fid_docids(word.interned(), fid)? { + docids |= word_fid_docids; } } for phrase in term.all_phrases(ctx)? { for &word in phrase.words(ctx).iter().flatten() { if let Some(word_fid_docids) = ctx.get_db_word_fid_docids(word, fid)? { - docids |= CboRoaringBitmapCodec::bytes_decode(word_fid_docids) - .ok_or(heed::Error::Decoding)?; + docids |= word_fid_docids; } } } if let Some(word_prefix) = term.use_prefix_db(ctx) { - if let Some(word_fid_docids) = ctx.get_db_word_prefix_fid_docids(word_prefix, fid)? { - docids |= CboRoaringBitmapCodec::bytes_decode(word_fid_docids) - .ok_or(heed::Error::Decoding)?; + if let Some(word_fid_docids) = + ctx.get_db_word_prefix_fid_docids(word_prefix.interned(), fid)? + { + docids |= word_fid_docids; } }