From 429cca2fccf2114e114730168fd2806637649dbe Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Thu, 10 Nov 2022 11:38:40 +0100 Subject: [PATCH 1/2] allow warming up of the full posting list --- src/core/inverted_index_reader.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/core/inverted_index_reader.rs b/src/core/inverted_index_reader.rs index 852db94ed5..b349f1e1ab 100644 --- a/src/core/inverted_index_reader.rs +++ b/src/core/inverted_index_reader.rs @@ -230,6 +230,26 @@ impl InvertedIndexReader { Ok(()) } + /// Read the block postings for all terms. + /// This method is for an advanced usage only. + /// + /// If you know which terms to pre-load, prefer using [`Self::warm_postings`] instead. + pub async fn warm_postings_full( + &self, + with_positions: bool, + ) -> crate::AsyncIoResult<()> { + self.postings_file_slice + .read_bytes_async() + .await?; + if with_positions { + self.positions_file_slice + .read_bytes_async() + .await?; + } + Ok(()) + } + + /// Returns the number of documents containing the term asynchronously. pub async fn doc_freq_async(&self, term: &Term) -> crate::AsyncIoResult { Ok(self From 9a43565ac39c2731833d935199322eafb410392e Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Thu, 10 Nov 2022 11:57:08 +0100 Subject: [PATCH 2/2] cargo fmt --- src/core/inverted_index_reader.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/core/inverted_index_reader.rs b/src/core/inverted_index_reader.rs index b349f1e1ab..ee144d68a8 100644 --- a/src/core/inverted_index_reader.rs +++ b/src/core/inverted_index_reader.rs @@ -234,22 +234,14 @@ impl InvertedIndexReader { /// This method is for an advanced usage only. /// /// If you know which terms to pre-load, prefer using [`Self::warm_postings`] instead. - pub async fn warm_postings_full( - &self, - with_positions: bool, - ) -> crate::AsyncIoResult<()> { - self.postings_file_slice - .read_bytes_async() - .await?; + pub async fn warm_postings_full(&self, with_positions: bool) -> crate::AsyncIoResult<()> { + self.postings_file_slice.read_bytes_async().await?; if with_positions { - self.positions_file_slice - .read_bytes_async() - .await?; + self.positions_file_slice.read_bytes_async().await?; } Ok(()) } - /// Returns the number of documents containing the term asynchronously. pub async fn doc_freq_async(&self, term: &Term) -> crate::AsyncIoResult { Ok(self