Skip to content

Commit

Permalink
refactor(storage): Refactoring pick_sub_level Improve code readability (
Browse files Browse the repository at this point in the history
  • Loading branch information
Li0k authored Feb 26, 2024
1 parent d50b4cb commit 8c1ecae
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 174 deletions.
13 changes: 4 additions & 9 deletions src/meta/src/hummock/compaction/overlap_strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,10 @@ impl OverlapInfo for RangeOverlapInfo {
if overlap_begin >= others.len() {
return overlap_begin..overlap_begin;
}
let mut overlap_end = overlap_begin;
for table in &others[overlap_begin..] {
if key_range.compare_right_with(&table.key_range.as_ref().unwrap().left)
== cmp::Ordering::Less
{
break;
}
overlap_end += 1;
}
let overlap_end = others.partition_point(|table_status| {
key_range.compare_right_with(&table_status.key_range.as_ref().unwrap().left)
!= cmp::Ordering::Less
});
overlap_begin..overlap_end
}
None => others.len()..others.len(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ pub mod tests {
);
let mut picker =
LevelCompactionPicker::new(1, config, Arc::new(CompactionDeveloperConfig::default()));

let ret = picker
.pick_compaction(&levels, &levels_handler, &mut local_stats)
.unwrap();
Expand Down
Loading

0 comments on commit 8c1ecae

Please sign in to comment.