Skip to content

Commit a706727

Browse files
committed
add option for manual compaction
Signed-off-by: Jason Volk <jason@zemos.net>
1 parent 9837f2c commit a706727

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/db.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,6 +2931,31 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
29312931
Ok(())
29322932
}
29332933

2934+
/// Enable or disable manual compaction.
2935+
///
2936+
/// false:
2937+
/// After this function call, CompactRange() or CompactFiles() will not
2938+
/// run compactions and fail. Calling this function will tell outstanding
2939+
/// manual compactions to abort and will wait for them to finish or abort
2940+
/// before returning.
2941+
///
2942+
/// true:
2943+
/// Re-enable CompactRange() and ComapctFiles() that are disabled by
2944+
/// DisableManualCompaction(). This function must be called as many times
2945+
/// as DisableManualCompaction() has been called in order to re-enable
2946+
/// manual compactions, and must not be called more times than
2947+
/// DisableManualCompaction() has been called.
2948+
#[inline]
2949+
pub fn enable_manual_compaction(&self, enable: bool) {
2950+
unsafe {
2951+
if enable {
2952+
ffi::rocksdb_enable_manual_compaction(self.inner.inner())
2953+
} else {
2954+
ffi::rocksdb_disable_manual_compaction(self.inner.inner())
2955+
}
2956+
}
2957+
}
2958+
29342959
pub fn set_options(&self, opts: &[(&str, &str)]) -> Result<(), Error> {
29352960
let copts = convert_options(opts)?;
29362961
let cnames: Vec<*const c_char> = copts.iter().map(|opt| opt.0.as_ptr()).collect();

0 commit comments

Comments
 (0)