Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions src/index/inverted_index_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ impl InvertedIndexReader {

#[cfg(feature = "quickwit")]
impl InvertedIndexReader {
pub(crate) async fn get_term_info_async(&self, term: &Term) -> io::Result<Option<TermInfo>> {
/// Resolves a `Term` to its [`TermInfo`] asynchronously, if present in the dictionary.
pub async fn get_term_info_async(&self, term: &Term) -> io::Result<Option<TermInfo>> {
self.termdict.get_async(term.serialized_value_bytes()).await
}

Expand Down Expand Up @@ -336,23 +337,38 @@ impl InvertedIndexReader {
pub async fn warm_postings(&self, term: &Term, with_positions: bool) -> io::Result<bool> {
let term_info_opt: Option<TermInfo> = 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.
///
Expand Down
Loading