-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: disjoint tree range optimization
- Loading branch information
1 parent
6d9089a
commit 019e721
Showing
6 changed files
with
174 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,36 @@ | ||
use super::{Choice, CompactionStrategy, Input}; | ||
use crate::{levels::LevelManifest, Config}; | ||
|
||
/// Pulls down and merges a level into the destination level. | ||
/// | ||
/// Used for unit tests. | ||
pub struct Strategy(pub u8, pub u8); | ||
|
||
impl CompactionStrategy for Strategy { | ||
#[allow(clippy::expect_used)] | ||
fn choose(&self, levels: &LevelManifest, _: &Config) -> Choice { | ||
let resolved_view = levels.resolved_view(); | ||
|
||
let level = resolved_view | ||
.get(usize::from(self.0)) | ||
.expect("level should exist"); | ||
|
||
let next_level = resolved_view | ||
.get(usize::from(self.1)) | ||
.expect("next level should exist"); | ||
|
||
let mut segment_ids = level | ||
.segments | ||
.iter() | ||
.map(|x| x.metadata.id) | ||
.collect::<Vec<_>>(); | ||
|
||
segment_ids.extend(next_level.segments.iter().map(|x| x.metadata.id)); | ||
|
||
Choice::Merge(Input { | ||
segment_ids, | ||
dest_level: self.1, | ||
target_size: 64_000_000, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters