Skip to content

Commit af87e95

Browse files
committed
fix: replace OpType with IndexBuildType in IndexerBuilderImpl
Signed-off-by: SNC123 <[email protected]>
1 parent 52ac84c commit af87e95

File tree

5 files changed

+39
-26
lines changed

5 files changed

+39
-26
lines changed

src/mito2/src/access_layer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl AccessLayer {
271271
let store = self.object_store.clone();
272272
let path_provider = RegionFilePathFactory::new(self.table_dir.clone(), self.path_type);
273273
let indexer_builder = IndexerBuilderImpl {
274-
op_type: request.op_type,
274+
build_type: request.op_type.into(),
275275
metadata: request.metadata.clone(),
276276
row_group_size: write_opts.row_group_size,
277277
puffin_manager: self

src/mito2/src/cache/write_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl WriteCache {
126126
let store = self.file_cache.local_store();
127127
let path_provider = WriteCachePathProvider::new(self.file_cache.clone());
128128
let indexer = IndexerBuilderImpl {
129-
op_type: write_request.op_type,
129+
build_type: write_request.op_type.into(),
130130
metadata: write_request.metadata.clone(),
131131
row_group_size: write_opts.row_group_size,
132132
puffin_manager: self

src/mito2/src/sst/index.rs

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub trait IndexerBuilder {
230230
}
231231
#[derive(Clone)]
232232
pub(crate) struct IndexerBuilderImpl {
233-
pub(crate) op_type: OperationType,
233+
pub(crate) build_type: IndexBuildType,
234234
pub(crate) metadata: RegionMetadataRef,
235235
pub(crate) row_group_size: usize,
236236
pub(crate) puffin_manager: SstPuffinManager,
@@ -270,9 +270,10 @@ impl IndexerBuilder for IndexerBuilderImpl {
270270

271271
impl IndexerBuilderImpl {
272272
fn build_inverted_indexer(&self, file_id: FileId) -> Option<InvertedIndexer> {
273-
let create = match self.op_type {
274-
OperationType::Flush => self.inverted_index_config.create_on_flush.auto(),
275-
OperationType::Compact => self.inverted_index_config.create_on_compaction.auto(),
273+
let create = match self.build_type {
274+
IndexBuildType::Flush => self.inverted_index_config.create_on_flush.auto(),
275+
IndexBuildType::Compact => self.inverted_index_config.create_on_compaction.auto(),
276+
_ => true,
276277
};
277278

278279
if !create {
@@ -330,9 +331,10 @@ impl IndexerBuilderImpl {
330331
}
331332

332333
async fn build_fulltext_indexer(&self, file_id: FileId) -> Option<FulltextIndexer> {
333-
let create = match self.op_type {
334-
OperationType::Flush => self.fulltext_index_config.create_on_flush.auto(),
335-
OperationType::Compact => self.fulltext_index_config.create_on_compaction.auto(),
334+
let create = match self.build_type {
335+
IndexBuildType::Flush => self.fulltext_index_config.create_on_flush.auto(),
336+
IndexBuildType::Compact => self.fulltext_index_config.create_on_compaction.auto(),
337+
_ => true,
336338
};
337339

338340
if !create {
@@ -383,9 +385,10 @@ impl IndexerBuilderImpl {
383385
}
384386

385387
fn build_bloom_filter_indexer(&self, file_id: FileId) -> Option<BloomFilterIndexer> {
386-
let create = match self.op_type {
387-
OperationType::Flush => self.bloom_filter_index_config.create_on_flush.auto(),
388-
OperationType::Compact => self.bloom_filter_index_config.create_on_compaction.auto(),
388+
let create = match self.build_type {
389+
IndexBuildType::Flush => self.bloom_filter_index_config.create_on_flush.auto(),
390+
IndexBuildType::Compact => self.bloom_filter_index_config.create_on_compaction.auto(),
391+
_ => true,
389392
};
390393

391394
if !create {
@@ -446,6 +449,15 @@ pub enum IndexBuildType {
446449
Manual,
447450
}
448451

452+
impl From<OperationType> for IndexBuildType {
453+
fn from(op_type: OperationType) -> Self {
454+
match op_type {
455+
OperationType::Flush => IndexBuildType::Flush,
456+
OperationType::Compact => IndexBuildType::Compact,
457+
}
458+
}
459+
}
460+
449461
#[derive(Debug, PartialEq, Clone)]
450462
pub enum IndexBuildOutcome {
451463
Finished,
@@ -672,6 +684,7 @@ mod tests {
672684
use object_store::ObjectStore;
673685
use object_store::services::Memory;
674686
use puffin_manager::PuffinManagerFactory;
687+
use serde_json::value::Index;
675688
use store_api::metadata::{ColumnMetadata, RegionMetadataBuilder};
676689
use tokio::sync::{mpsc, oneshot};
677690

@@ -830,7 +843,7 @@ mod tests {
830843
),
831844
);
832845
Arc::new(IndexerBuilderImpl {
833-
op_type: OperationType::Flush,
846+
build_type: IndexBuildType::Flush,
834847
metadata,
835848
row_group_size: 1024,
836849
puffin_manager,
@@ -854,7 +867,7 @@ mod tests {
854867
with_skipping_bloom: true,
855868
});
856869
let indexer = IndexerBuilderImpl {
857-
op_type: OperationType::Flush,
870+
build_type: IndexBuildType::Flush,
858871
metadata,
859872
row_group_size: 1024,
860873
puffin_manager: factory.build(mock_object_store(), NoopPathProvider),
@@ -884,7 +897,7 @@ mod tests {
884897
with_skipping_bloom: true,
885898
});
886899
let indexer = IndexerBuilderImpl {
887-
op_type: OperationType::Flush,
900+
build_type: IndexBuildType::Flush,
888901
metadata: metadata.clone(),
889902
row_group_size: 1024,
890903
puffin_manager: factory.build(mock_object_store(), NoopPathProvider),
@@ -905,7 +918,7 @@ mod tests {
905918
assert!(indexer.bloom_filter_indexer.is_some());
906919

907920
let indexer = IndexerBuilderImpl {
908-
op_type: OperationType::Compact,
921+
build_type: IndexBuildType::Compact,
909922
metadata: metadata.clone(),
910923
row_group_size: 1024,
911924
puffin_manager: factory.build(mock_object_store(), NoopPathProvider),
@@ -926,7 +939,7 @@ mod tests {
926939
assert!(indexer.bloom_filter_indexer.is_some());
927940

928941
let indexer = IndexerBuilderImpl {
929-
op_type: OperationType::Compact,
942+
build_type: IndexBuildType::Compact,
930943
metadata,
931944
row_group_size: 1024,
932945
puffin_manager: factory.build(mock_object_store(), NoopPathProvider),
@@ -959,7 +972,7 @@ mod tests {
959972
with_skipping_bloom: true,
960973
});
961974
let indexer = IndexerBuilderImpl {
962-
op_type: OperationType::Flush,
975+
build_type: IndexBuildType::Flush,
963976
metadata: metadata.clone(),
964977
row_group_size: 1024,
965978
puffin_manager: factory.build(mock_object_store(), NoopPathProvider),
@@ -982,7 +995,7 @@ mod tests {
982995
with_skipping_bloom: true,
983996
});
984997
let indexer = IndexerBuilderImpl {
985-
op_type: OperationType::Flush,
998+
build_type: IndexBuildType::Flush,
986999
metadata: metadata.clone(),
9871000
row_group_size: 1024,
9881001
puffin_manager: factory.build(mock_object_store(), NoopPathProvider),
@@ -1005,7 +1018,7 @@ mod tests {
10051018
with_skipping_bloom: false,
10061019
});
10071020
let indexer = IndexerBuilderImpl {
1008-
op_type: OperationType::Flush,
1021+
build_type: IndexBuildType::Flush,
10091022
metadata: metadata.clone(),
10101023
row_group_size: 1024,
10111024
puffin_manager: factory.build(mock_object_store(), NoopPathProvider),
@@ -1035,7 +1048,7 @@ mod tests {
10351048
with_skipping_bloom: true,
10361049
});
10371050
let indexer = IndexerBuilderImpl {
1038-
op_type: OperationType::Flush,
1051+
build_type: IndexBuildType::Flush,
10391052
metadata,
10401053
row_group_size: 0,
10411054
puffin_manager: factory.build(mock_object_store(), NoopPathProvider),
@@ -1317,7 +1330,7 @@ mod tests {
13171330
);
13181331
// Indexer builder built from write cache.
13191332
let indexer_builder = Arc::new(IndexerBuilderImpl {
1320-
op_type: OperationType::Flush,
1333+
build_type: IndexBuildType::Flush,
13211334
metadata: metadata.clone(),
13221335
row_group_size: 1024,
13231336
puffin_manager: write_cache.build_puffin_manager().clone(),

src/mito2/src/sst/parquet.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ mod tests {
120120
use crate::sst::file_purger::NoopFilePurger;
121121
use crate::sst::index::bloom_filter::applier::BloomFilterIndexApplierBuilder;
122122
use crate::sst::index::inverted_index::applier::builder::InvertedIndexApplierBuilder;
123-
use crate::sst::index::{Indexer, IndexerBuilder, IndexerBuilderImpl};
123+
use crate::sst::index::{IndexBuildType, Indexer, IndexerBuilder, IndexerBuilderImpl};
124124
use crate::sst::parquet::format::PrimaryKeyWriteFormat;
125125
use crate::sst::parquet::reader::{ParquetReader, ParquetReaderBuilder, ReaderMetrics};
126126
use crate::sst::parquet::writer::ParquetWriter;
@@ -699,7 +699,7 @@ mod tests {
699699
let intermediate_manager = env.get_intermediate_manager();
700700

701701
let indexer_builder = IndexerBuilderImpl {
702-
op_type: OperationType::Flush,
702+
build_type: IndexBuildType::Flush,
703703
metadata: metadata.clone(),
704704
row_group_size,
705705
puffin_manager,
@@ -1075,7 +1075,7 @@ mod tests {
10751075
let intermediate_manager = env.get_intermediate_manager();
10761076

10771077
let indexer_builder = IndexerBuilderImpl {
1078-
op_type: OperationType::Flush,
1078+
build_type: IndexBuildType::Flush,
10791079
metadata: metadata.clone(),
10801080
row_group_size,
10811081
puffin_manager,

src/mito2/src/worker/handle_rebuild_index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<S> RegionWorkerLoop<S> {
6060
};
6161

6262
let indexer_builder_ref = Arc::new(IndexerBuilderImpl {
63-
op_type: OperationType::Flush, //TODO(SNC123): Temporarily set to Flush, 4 BuildTypes will be introduced later.
63+
build_type: build_type.clone(),
6464
metadata: version.metadata.clone(),
6565
inverted_index_config: self.config.inverted_index.clone(),
6666
fulltext_index_config: self.config.fulltext_index.clone(),

0 commit comments

Comments
 (0)