fix(compaction): correct level0_file_num_compaction_trigger in simple leveled compaction (#112)

* fix(compaction): correct level0_file_num_compaction_trigger in simple leveled compaction

Signed-off-by: zztaki <zztaki@outlook.com>

* minor nit + sync to mvcc version

Signed-off-by: Alex Chi <iskyzh@gmail.com>

---------

Signed-off-by: zztaki <zztaki@outlook.com>
Signed-off-by: Alex Chi <iskyzh@gmail.com>
Co-authored-by: Alex Chi <iskyzh@gmail.com>
This commit is contained in:
Zhelong Zhao
2024-12-30 07:23:28 +08:00
committed by GitHub
parent 0a91335140
commit cc1b174515
2 changed files with 39 additions and 12 deletions

View File

@@ -43,6 +43,22 @@ impl SimpleLeveledCompactionController {
level_sizes.push(files.len());
}
// check level0_file_num_compaction_trigger for compaction of L0 to L1
if snapshot.l0_sstables.len() >= self.options.level0_file_num_compaction_trigger {
println!(
"compaction triggered at level 0 because L0 has {} SSTs >= {}",
snapshot.l0_sstables.len(),
self.options.level0_file_num_compaction_trigger
);
return Some(SimpleLeveledCompactionTask {
upper_level: None,
upper_level_sst_ids: snapshot.l0_sstables.clone(),
lower_level: 1,
lower_level_sst_ids: snapshot.levels[0].1.clone(),
is_lower_level_bottom_level: false,
});
}
for i in 0..self.options.max_levels {
if i == 0
&& snapshot.l0_sstables.len() < self.options.level0_file_num_compaction_trigger