From d2159cbb3608e5b9bbe8d9721597e453ba491c89 Mon Sep 17 00:00:00 2001 From: CookiePieWw Date: Mon, 9 Dec 2024 15:20:13 +0800 Subject: [PATCH] chore: apply review comments --- src/index/src/inverted_index/format/reader.rs | 9 +++------ src/index/src/inverted_index/format/reader/blob.rs | 11 +---------- src/mito2/src/cache/index.rs | 13 +++---------- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/src/index/src/inverted_index/format/reader.rs b/src/index/src/inverted_index/format/reader.rs index a6fb0cecbfcd..5fb45b2e6216 100644 --- a/src/index/src/inverted_index/format/reader.rs +++ b/src/index/src/inverted_index/format/reader.rs @@ -30,23 +30,20 @@ mod footer; #[mockall::automock] #[async_trait] pub trait InvertedIndexReader: Send { - /// Reads all data to dest. - async fn read_all(&mut self, dest: &mut Vec) -> Result; - /// Seeks to given offset and reads data with exact size as provided. - async fn seek_read(&mut self, offset: u64, size: u32) -> Result>; + async fn range_read(&mut self, offset: u64, size: u32) -> Result>; /// Retrieves metadata of all inverted indices stored within the blob. async fn metadata(&mut self) -> Result>; /// Retrieves the finite state transducer (FST) map from the given offset and size. async fn fst(&mut self, offset: u64, size: u32) -> Result { - let fst_data = self.seek_read(offset, size).await?; + let fst_data = self.range_read(offset, size).await?; FstMap::new(fst_data).context(DecodeFstSnafu) } /// Retrieves the bitmap from the given offset and size. async fn bitmap(&mut self, offset: u64, size: u32) -> Result { - self.seek_read(offset, size).await.map(BitVec::from_vec) + self.range_read(offset, size).await.map(BitVec::from_vec) } } diff --git a/src/index/src/inverted_index/format/reader/blob.rs b/src/index/src/inverted_index/format/reader/blob.rs index ace0e5c48536..b8f74b521abd 100644 --- a/src/index/src/inverted_index/format/reader/blob.rs +++ b/src/index/src/inverted_index/format/reader/blob.rs @@ -49,16 +49,7 @@ impl InvertedIndexBlobReader { #[async_trait] impl InvertedIndexReader for InvertedIndexBlobReader { - async fn read_all(&mut self, dest: &mut Vec) -> Result { - let metadata = self.source.metadata().await.context(CommonIoSnafu)?; - self.source - .read_into(0..metadata.content_length, dest) - .await - .context(CommonIoSnafu)?; - Ok(metadata.content_length as usize) - } - - async fn seek_read(&mut self, offset: u64, size: u32) -> Result> { + async fn range_read(&mut self, offset: u64, size: u32) -> Result> { let buf = self .source .read(offset..offset + size as u64) diff --git a/src/mito2/src/cache/index.rs b/src/mito2/src/cache/index.rs index 14345a7256c0..c80d58fd180a 100644 --- a/src/mito2/src/cache/index.rs +++ b/src/mito2/src/cache/index.rs @@ -78,7 +78,7 @@ where None => { let page = self .inner - .seek_read( + .range_read( index.page_id * (self.cache.page_size as u64), self.cache.page_size as u32, ) @@ -106,19 +106,12 @@ where #[async_trait] impl InvertedIndexReader for CachedInvertedIndexBlobReader { - async fn read_all( - &mut self, - dest: &mut Vec, - ) -> index::inverted_index::error::Result { - self.inner.read_all(dest).await - } - - async fn seek_read( + async fn range_read( &mut self, offset: u64, size: u32, ) -> index::inverted_index::error::Result> { - self.inner.seek_read(offset, size).await + self.inner.range_read(offset, size).await } async fn metadata(&mut self) -> index::inverted_index::error::Result> {