-
Notifications
You must be signed in to change notification settings - Fork 599
Open
Description
I have codes for you if you don't mind:
fn find_overlapping_ssts(
&self,
snapshot: &LsmStorageState,
sst_ids: &[usize],
in_level: usize,
) -> Vec<usize> {
let begin_key = sst_ids
.iter()
.map(|id| snapshot.sstables[id].first_key())
.min()
.cloned()
.unwrap();
let end_key = sst_ids
.iter()
.map(|id| snapshot.sstables[id].last_key())
.max()
.cloned()
.unwrap();
let mut sstables = Vec::with_capacity(snapshot.levels[in_level - 1].1.len());
for sst_id in &snapshot.levels[in_level - 1].1 {
sstables.push(snapshot.sstables[sst_id].clone());
}
if sstables.is_empty() {
return Vec::new();
}
let mut sst_ids = Vec::new();
let lower = sstables.partition_point(|table| table.last_key().as_key_slice() < begin_key.as_key_slice());
let upper = sstables
.partition_point(|table| table.first_key().as_key_slice() <= end_key.as_key_slice())
.saturating_sub(1);
println!(
"[leveled compaction] level {} find overlapping ssts, lower: {}, upper: {}",
in_level, lower, upper
);
sst_ids.extend(
sstables[lower..=upper]
.iter()
.map(|table| table.sst_id())
.collect::<Vec<usize>>(),
);
sst_ids
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels