From b1e4c3a96652030efb6bb8f20f556fd94f059e55 Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Thu, 25 Jun 2026 09:55:59 +0100 Subject: [PATCH] make get_term_info_async pub --- src/index/inverted_index_reader.rs | 40 +++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/index/inverted_index_reader.rs b/src/index/inverted_index_reader.rs index 7314f87417..d34d456f18 100644 --- a/src/index/inverted_index_reader.rs +++ b/src/index/inverted_index_reader.rs @@ -283,7 +283,8 @@ impl InvertedIndexReader { #[cfg(feature = "quickwit")] impl InvertedIndexReader { - pub(crate) async fn get_term_info_async(&self, term: &Term) -> io::Result> { + /// Resolves a `Term` to its [`TermInfo`] asynchronously, if present in the dictionary. + pub async fn get_term_info_async(&self, term: &Term) -> io::Result> { self.termdict.get_async(term.serialized_value_bytes()).await } @@ -336,23 +337,38 @@ impl InvertedIndexReader { pub async fn warm_postings(&self, term: &Term, with_positions: bool) -> io::Result { let term_info_opt: Option = self.get_term_info_async(term).await?; if let Some(term_info) = term_info_opt { - let postings = self - .postings_file_slice - .read_bytes_slice_async(term_info.postings_range.clone()); - if with_positions { - let positions = self - .positions_file_slice - .read_bytes_slice_async(term_info.positions_range.clone()); - futures_util::future::try_join(postings, positions).await?; - } else { - postings.await?; - } + self.warm_postings_from_term_info(&term_info, with_positions) + .await?; Ok(true) } else { Ok(false) } } + /// Warmup a block postings given a `TermInfo`. + /// This method is for an advanced usage only. + /// + /// Use this when the [`TermInfo`] is already known (e.g. resolved via + /// [`Self::get_term_info_async`]) to avoid a redundant dictionary lookup. + pub async fn warm_postings_from_term_info( + &self, + term_info: &TermInfo, + with_positions: bool, + ) -> io::Result<()> { + let postings = self + .postings_file_slice + .read_bytes_slice_async(term_info.postings_range.clone()); + if with_positions { + let positions = self + .positions_file_slice + .read_bytes_slice_async(term_info.positions_range.clone()); + futures_util::future::try_join(postings, positions).await?; + } else { + postings.await?; + } + Ok(()) + } + /// Warmup a block postings given a range of `Term`s. /// This method is for an advanced usage only. ///