refactor: rename TargetLevelDetection to TargetLevelChooser

pull/24376/head
NGA-TRAN 2023-02-03 17:28:33 -05:00
parent 930a40f6f6
commit f071a3674e
5 changed files with 32 additions and 32 deletions

View File

@ -62,9 +62,9 @@ use super::{
round_split::all_now::AllNowRoundSplit,
scratchpad::{ignore_writes_object_store::IgnoreWrites, prod::ProdScratchpadGen},
skipped_compactions_source::catalog::CatalogSkippedCompactionsSource,
target_level_detection::{
all_at_once::AllAtOnceTargetLevelDetection, target_level::TargetLevelTargetLevelDetection,
TargetLevelDetection,
target_level_chooser::{
all_at_once::AllAtOnceTargetLevelChooser, target_level::TargetLevelTargetLevelChooser,
TargetLevelChooser,
},
Components,
};
@ -286,11 +286,11 @@ fn version_specific_partition_filters(config: &Config) -> Vec<Arc<dyn PartitionF
}
}
fn version_specific_target_level_detection(config: &Config) -> Arc<dyn TargetLevelDetection> {
fn version_specific_target_level_detection(config: &Config) -> Arc<dyn TargetLevelChooser> {
match config.compact_version {
AlgoVersion::AllAtOnce => Arc::new(AllAtOnceTargetLevelDetection::new()),
AlgoVersion::AllAtOnce => Arc::new(AllAtOnceTargetLevelChooser::new()),
AlgoVersion::TargetLevel => {
Arc::new(TargetLevelTargetLevelDetection::new(OneLevelExist::new()))
Arc::new(TargetLevelTargetLevelChooser::new(OneLevelExist::new()))
}
}
}

View File

@ -7,7 +7,7 @@ use self::{
partition_files_source::PartitionFilesSource, partition_filter::PartitionFilter,
partition_source::PartitionSource, partitions_source::PartitionsSource,
round_split::RoundSplit, scratchpad::ScratchpadGen, tables_source::TablesSource,
target_level_detection::TargetLevelDetection,
target_level_chooser::TargetLevelChooser,
};
pub mod combos;
@ -32,7 +32,7 @@ pub mod round_split;
pub mod scratchpad;
pub mod skipped_compactions_source;
pub mod tables_source;
pub mod target_level_detection;
pub mod target_level_chooser;
#[derive(Debug, Clone)]
pub struct Components {
@ -51,5 +51,5 @@ pub struct Components {
pub round_split: Arc<dyn RoundSplit>,
pub divide_initial: Arc<dyn DivideInitial>,
pub scratchpad_gen: Arc<dyn ScratchpadGen>,
pub target_level_detection: Arc<dyn TargetLevelDetection>,
pub target_level_detection: Arc<dyn TargetLevelChooser>,
}

View File

@ -2,24 +2,24 @@ use std::fmt::Display;
use data_types::CompactionLevel;
use super::TargetLevelDetection;
use super::TargetLevelChooser;
#[derive(Debug)]
pub struct AllAtOnceTargetLevelDetection {}
pub struct AllAtOnceTargetLevelChooser {}
impl AllAtOnceTargetLevelDetection {
impl AllAtOnceTargetLevelChooser {
pub fn new() -> Self {
Self {}
}
}
impl Display for AllAtOnceTargetLevelDetection {
impl Display for AllAtOnceTargetLevelChooser {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Target level detection for AllAtOnce version",)
}
}
impl TargetLevelDetection for AllAtOnceTargetLevelDetection {
impl TargetLevelChooser for AllAtOnceTargetLevelChooser {
// For AllAtOnce version, we only compact (L0s + L1s) to L1s
// The target level is always 1 and there must be at least one file in L0
fn detect(&self, files: &[data_types::ParquetFile]) -> CompactionLevel {
@ -44,7 +44,7 @@ mod tests {
#[test]
fn test_display() {
assert_eq!(
AllAtOnceTargetLevelDetection::new().to_string(),
AllAtOnceTargetLevelChooser::new().to_string(),
"Target level detection for AllAtOnce version"
);
}
@ -52,7 +52,7 @@ mod tests {
#[test]
#[should_panic(expected = "Level-0 file not found in target level detection")]
fn test_apply_empty() {
let target_level_detection = AllAtOnceTargetLevelDetection::new();
let target_level_detection = AllAtOnceTargetLevelChooser::new();
target_level_detection.detect(&[]);
}
@ -60,7 +60,7 @@ mod tests {
#[test]
#[should_panic(expected = "Level-0 file not found in target level detection")]
fn test_only_l1() {
let target_level_detection = AllAtOnceTargetLevelDetection::new();
let target_level_detection = AllAtOnceTargetLevelChooser::new();
let f1 = ParquetFileBuilder::new(1)
.with_compaction_level(CompactionLevel::FileNonOverlapped)
@ -72,7 +72,7 @@ mod tests {
#[test]
#[should_panic(expected = "Level-0 file not found in target level detection")]
fn test_only_l2() {
let target_level_detection = AllAtOnceTargetLevelDetection::new();
let target_level_detection = AllAtOnceTargetLevelChooser::new();
let f2 = ParquetFileBuilder::new(2)
.with_compaction_level(CompactionLevel::Final)
@ -84,7 +84,7 @@ mod tests {
#[test]
#[should_panic(expected = "Level-0 file not found in target level detection")]
fn test_only_l1_l2() {
let target_level_detection = AllAtOnceTargetLevelDetection::new();
let target_level_detection = AllAtOnceTargetLevelChooser::new();
let f1 = ParquetFileBuilder::new(1)
.with_compaction_level(CompactionLevel::FileNonOverlapped)
@ -99,7 +99,7 @@ mod tests {
#[test]
fn test_apply() {
let target_level_detection = AllAtOnceTargetLevelDetection::new();
let target_level_detection = AllAtOnceTargetLevelChooser::new();
let f0 = ParquetFileBuilder::new(0)
.with_compaction_level(CompactionLevel::Initial)

View File

@ -5,7 +5,7 @@ use data_types::CompactionLevel;
pub mod all_at_once;
pub mod target_level;
pub trait TargetLevelDetection: Debug + Display + Send + Sync {
pub trait TargetLevelChooser: Debug + Display + Send + Sync {
/// Return the compaction level the given files are suitable to get compacted to
fn detect(&self, files: &[data_types::ParquetFile]) -> CompactionLevel;
}

View File

@ -4,19 +4,19 @@ use data_types::CompactionLevel;
use crate::components::level_exist::LevelExist;
use super::TargetLevelDetection;
use super::TargetLevelChooser;
/// For TargetLevel version, we support compact (L0s + L1s) to L1s and (L1s + L2s) to L2s
/// Target is the next level of the lowest level that has files
#[derive(Debug)]
pub struct TargetLevelTargetLevelDetection<T>
pub struct TargetLevelTargetLevelChooser<T>
where
T: LevelExist,
{
inner: T,
}
impl<T> TargetLevelTargetLevelDetection<T>
impl<T> TargetLevelTargetLevelChooser<T>
where
T: LevelExist,
{
@ -25,7 +25,7 @@ where
}
}
impl<T> Display for TargetLevelTargetLevelDetection<T>
impl<T> Display for TargetLevelTargetLevelChooser<T>
where
T: LevelExist,
{
@ -34,7 +34,7 @@ where
}
}
impl<T> TargetLevelDetection for TargetLevelTargetLevelDetection<T>
impl<T> TargetLevelChooser for TargetLevelTargetLevelChooser<T>
where
T: LevelExist,
{
@ -65,7 +65,7 @@ mod tests {
#[test]
fn test_display() {
assert_eq!(
TargetLevelTargetLevelDetection::new(OneLevelExist::new()).to_string(),
TargetLevelTargetLevelChooser::new(OneLevelExist::new()).to_string(),
"Target level detection for TargetLevel version"
);
}
@ -73,14 +73,14 @@ mod tests {
#[test]
#[should_panic(expected = "Neither level-0 nor level-1 found in target level detection")]
fn test_apply_empty() {
let target_level_detection = TargetLevelTargetLevelDetection::new(OneLevelExist::new());
let target_level_detection = TargetLevelTargetLevelChooser::new(OneLevelExist::new());
target_level_detection.detect(&[]);
}
#[test]
fn test_apply_only_l0() {
let target_level_detection = TargetLevelTargetLevelDetection::new(OneLevelExist::new());
let target_level_detection = TargetLevelTargetLevelChooser::new(OneLevelExist::new());
let f0 = ParquetFileBuilder::new(0)
.with_compaction_level(CompactionLevel::Initial)
@ -94,7 +94,7 @@ mod tests {
#[test]
fn test_apply_only_l1() {
let target_level_detection = TargetLevelTargetLevelDetection::new(OneLevelExist::new());
let target_level_detection = TargetLevelTargetLevelChooser::new(OneLevelExist::new());
let f1 = ParquetFileBuilder::new(1)
.with_compaction_level(CompactionLevel::FileNonOverlapped)
@ -106,7 +106,7 @@ mod tests {
#[test]
#[should_panic(expected = "Neither level-0 nor level-1 found in target level detection")]
fn test_apply_only_l2() {
let target_level_detection = TargetLevelTargetLevelDetection::new(OneLevelExist::new());
let target_level_detection = TargetLevelTargetLevelChooser::new(OneLevelExist::new());
let f2 = ParquetFileBuilder::new(2)
.with_compaction_level(CompactionLevel::Final)
@ -117,7 +117,7 @@ mod tests {
#[test]
fn test_apply_many_files() {
let target_level_detection = TargetLevelTargetLevelDetection::new(OneLevelExist::new());
let target_level_detection = TargetLevelTargetLevelChooser::new(OneLevelExist::new());
let f0 = ParquetFileBuilder::new(0)
.with_compaction_level(CompactionLevel::Initial)