Skip to content

Commit 587f025

Browse files
committed
feat: major compaction API, closes #105
hidden for now
1 parent debb55b commit 587f025

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Diff for: src/partition/mod.rs

+22
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,28 @@ impl PartitionHandle {
895895
)
896896
}
897897

898+
/// Performs major compaction, blocking the caller until it's done.
899+
///
900+
/// # Errors
901+
///
902+
/// Will return `Err` if an IO error occurs.
903+
#[doc(hidden)]
904+
pub fn major_compact(&self) -> crate::Result<()> {
905+
match &self.config.compaction_strategy {
906+
crate::compaction::Strategy::Leveled(x) => self.tree.major_compact(
907+
u64::from(x.target_size),
908+
self.snapshot_tracker.get_seqno_safe_to_gc(),
909+
)?,
910+
crate::compaction::Strategy::SizeTiered(_) => self
911+
.tree
912+
.major_compact(u64::MAX, self.snapshot_tracker.get_seqno_safe_to_gc())?,
913+
crate::compaction::Strategy::Fifo(_) => {
914+
log::warn!("Major compaction not supported for FIFO strategy");
915+
}
916+
}
917+
Ok(())
918+
}
919+
898920
/// Inserts a key-value pair into the partition.
899921
///
900922
/// Keys may be up to 65536 bytes long, values up to 2^32 bytes.

0 commit comments

Comments
 (0)