From 8fd444444ebf745eebba46364b1f47cb58e19789 Mon Sep 17 00:00:00 2001
From: WenyXu
Date: Wed, 11 Dec 2024 18:11:52 +0000
Subject: [PATCH] refactor: remove too_many_arguments
---
src/mito2/src/read/scan_region.rs | 6 +-
.../src/sst/index/inverted_index/applier.rs | 38 ++++++++-----
.../index/inverted_index/applier/builder.rs | 57 ++++++++++++-------
.../inverted_index/applier/builder/between.rs | 15 -----
.../applier/builder/comparison.rs | 12 ----
.../inverted_index/applier/builder/eq_list.rs | 21 -------
.../inverted_index/applier/builder/in_list.rs | 15 -----
.../applier/builder/regex_match.rs | 12 ----
.../src/sst/index/inverted_index/creator.rs | 5 +-
9 files changed, 65 insertions(+), 116 deletions(-)
diff --git a/src/mito2/src/read/scan_region.rs b/src/mito2/src/read/scan_region.rs
index 8ea51d7a435e..32b8c90cda02 100644
--- a/src/mito2/src/read/scan_region.rs
+++ b/src/mito2/src/read/scan_region.rs
@@ -422,8 +422,6 @@ impl ScanRegion {
InvertedIndexApplierBuilder::new(
self.access_layer.region_dir().to_string(),
self.access_layer.object_store().clone(),
- file_cache,
- index_cache,
self.version.metadata.as_ref(),
self.version.metadata.inverted_indexed_column_ids(
self.version
@@ -434,8 +432,10 @@ impl ScanRegion {
.iter(),
),
self.access_layer.puffin_manager_factory().clone(),
- puffin_metadata_cache,
)
+ .with_file_cache(file_cache)
+ .with_index_cache(index_cache)
+ .with_puffin_metadata_cache(puffin_metadata_cache)
.build(&self.request.filters)
.inspect_err(|err| warn!(err; "Failed to build invereted index applier"))
.ok()
diff --git a/src/mito2/src/sst/index/inverted_index/applier.rs b/src/mito2/src/sst/index/inverted_index/applier.rs
index 42be7f7756b2..bf5206ef44be 100644
--- a/src/mito2/src/sst/index/inverted_index/applier.rs
+++ b/src/mito2/src/sst/index/inverted_index/applier.rs
@@ -69,16 +69,11 @@ pub(crate) struct InvertedIndexApplier {
pub(crate) type InvertedIndexApplierRef = Arc;
impl InvertedIndexApplier {
- // TODO(weny): remove this after refactoring.
- #[allow(clippy::too_many_arguments)]
/// Creates a new `InvertedIndexApplier`.
pub fn new(
region_dir: String,
region_id: RegionId,
store: ObjectStore,
- file_cache: Option,
- index_cache: Option,
- puffin_metadata_cache: Option,
index_applier: Box,
puffin_manager_factory: PuffinManagerFactory,
) -> Self {
@@ -88,14 +83,35 @@ impl InvertedIndexApplier {
region_dir,
region_id,
store,
- file_cache,
+ file_cache: None,
index_applier,
puffin_manager_factory,
- inverted_index_cache: index_cache,
- puffin_metadata_cache,
+ inverted_index_cache: None,
+ puffin_metadata_cache: None,
}
}
+ /// Sets the file cache.
+ pub fn with_file_cache(mut self, file_cache: Option) -> Self {
+ self.file_cache = file_cache;
+ self
+ }
+
+ /// Sets the index cache.
+ pub fn with_index_cache(mut self, index_cache: Option) -> Self {
+ self.inverted_index_cache = index_cache;
+ self
+ }
+
+ /// Sets the puffin metadata cache.
+ pub fn with_puffin_metadata_cache(
+ mut self,
+ puffin_metadata_cache: Option,
+ ) -> Self {
+ self.puffin_metadata_cache = puffin_metadata_cache;
+ self
+ }
+
/// Applies predicates to the provided SST file id and returns the relevant row group ids
pub async fn apply(&self, file_id: FileId) -> Result {
let _timer = INDEX_APPLY_ELAPSED
@@ -231,9 +247,6 @@ mod tests {
region_dir.clone(),
RegionId::new(0, 0),
object_store,
- None,
- None,
- None,
Box::new(mock_index_applier),
puffin_manager_factory,
);
@@ -274,9 +287,6 @@ mod tests {
region_dir.clone(),
RegionId::new(0, 0),
object_store,
- None,
- None,
- None,
Box::new(mock_index_applier),
puffin_manager_factory,
);
diff --git a/src/mito2/src/sst/index/inverted_index/applier/builder.rs b/src/mito2/src/sst/index/inverted_index/applier/builder.rs
index 131325816fb6..653679b9fca8 100644
--- a/src/mito2/src/sst/index/inverted_index/applier/builder.rs
+++ b/src/mito2/src/sst/index/inverted_index/applier/builder.rs
@@ -72,32 +72,48 @@ pub(crate) struct InvertedIndexApplierBuilder<'a> {
}
impl<'a> InvertedIndexApplierBuilder<'a> {
- // TODO(weny): remove this after refactoring.
- #[allow(clippy::too_many_arguments)]
/// Creates a new [`InvertedIndexApplierBuilder`].
pub fn new(
region_dir: String,
object_store: ObjectStore,
- file_cache: Option,
- index_cache: Option,
metadata: &'a RegionMetadata,
indexed_column_ids: HashSet,
puffin_manager_factory: PuffinManagerFactory,
- puffin_metadata_cache: Option,
) -> Self {
Self {
region_dir,
object_store,
- file_cache,
metadata,
indexed_column_ids,
output: HashMap::default(),
- index_cache,
puffin_manager_factory,
- puffin_metadata_cache,
+ file_cache: None,
+ index_cache: None,
+ puffin_metadata_cache: None,
}
}
+ /// Sets the file cache.
+ pub fn with_file_cache(mut self, file_cache: Option) -> Self {
+ self.file_cache = file_cache;
+ self
+ }
+
+ /// Sets the puffin metadata cache.
+ pub fn with_puffin_metadata_cache(
+ mut self,
+ puffin_metadata_cache: Option,
+ ) -> Self {
+ self.puffin_metadata_cache = puffin_metadata_cache;
+ self
+ }
+
+ /// Sets the index cache.
+ pub fn with_index_cache(mut self, index_cache: Option) -> Self {
+ self.index_cache = index_cache;
+ self
+ }
+
/// Consumes the builder to construct an [`InvertedIndexApplier`], optionally returned based on
/// the expressions provided. If no predicates match, returns `None`.
pub fn build(mut self, exprs: &[Expr]) -> Result