checkin part 2 solution

Signed-off-by: Alex Chi <iskyzh@gmail.com>
This commit is contained in:
Alex Chi
2024-01-24 14:32:13 +08:00
parent 9c4057c166
commit 9473c89330
25 changed files with 945 additions and 253 deletions

View File

@@ -343,6 +343,7 @@ fn main() {
} else {
storage.dump_original_id(false, false);
}
println!("--- Compaction Task ---");
let mut num_compactions = 0;
while let Some(task) = {
println!("--- Compaction Task ---");

View File

@@ -107,6 +107,19 @@ fn main() -> Result<()> {
} else {
println!("{} not exist", key);
}
} else if line == "scan" {
let mut iter = lsm.scan(std::ops::Bound::Unbounded, std::ops::Bound::Unbounded)?;
let mut cnt = 0;
while iter.is_valid() {
println!(
"{:?}={:?}",
Bytes::copy_from_slice(iter.key()),
Bytes::copy_from_slice(iter.value()),
);
iter.next()?;
cnt += 1;
}
println!("{} keys scanned", cnt);
} else if line.starts_with("scan ") {
let Some((_, rest)) = line.split_once(' ') else {
println!("invalid command");
@@ -137,7 +150,7 @@ fn main() -> Result<()> {
lsm.force_flush()?;
} else if line == "full_compaction" {
lsm.force_full_compaction()?;
} else if line == "quit" {
} else if line == "quit" || line == "close" {
lsm.close()?;
break;
} else {