From 406b8bd2489931afb2373ed60011e73d9530922e Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Tue, 4 Apr 2023 17:04:46 +0200 Subject: [PATCH] Add new db caches --- milli/src/search/new/db_cache.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/milli/src/search/new/db_cache.rs b/milli/src/search/new/db_cache.rs index af94108e2..effd123be 100644 --- a/milli/src/search/new/db_cache.rs +++ b/milli/src/search/new/db_cache.rs @@ -24,6 +24,8 @@ pub struct DatabaseCache<'ctx> { pub word_docids: FxHashMap, Option<&'ctx [u8]>>, pub exact_word_docids: FxHashMap, Option<&'ctx [u8]>>, pub word_prefix_docids: FxHashMap, Option<&'ctx [u8]>>, + pub word_position_docids: FxHashMap<(Interned, u16), Option<&'ctx [u8]>>, + pub word_fid_docids: FxHashMap<(Interned, u16), Option<&'ctx [u8]>>, } impl<'ctx> DatabaseCache<'ctx> { fn get_value<'v, K1, KC>( @@ -128,4 +130,32 @@ impl<'ctx> SearchContext<'ctx> { self.index.prefix_word_pair_proximity_docids.remap_data_type::(), ) } + + pub fn get_db_word_position_docids( + &mut self, + word: Interned, + position: u16, + ) -> Result> { + DatabaseCache::get_value( + self.txn, + (word, position), + &(self.word_interner.get(word).as_str(), position), + &mut self.db_cache.word_position_docids, + self.index.word_position_docids.remap_data_type::(), + ) + } + + pub fn get_db_word_fid_docids( + &mut self, + word: Interned, + fid: u16, + ) -> Result> { + DatabaseCache::get_value( + self.txn, + (word, fid), + &(self.word_interner.get(word).as_str(), fid), + &mut self.db_cache.word_fid_docids, + self.index.word_fid_docids.remap_data_type::(), + ) + } }