diff --git a/src/ffi.rs b/src/ffi.rs index 23f641d..19634fc 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -206,6 +206,8 @@ extern "C" { v: c_int); pub fn rocksdb_options_set_report_bg_io_stats(options: DBOptions, v: c_int); pub fn rocksdb_options_set_wal_recovery_mode(options: DBOptions, mode: DBRecoveryMode); + pub fn rocksdb_options_enable_statistics(options: DBOptions); + pub fn rocksdb_options_set_stats_dump_period_sec(options: DBOptions, v: usize); pub fn rocksdb_filterpolicy_create_bloom_full(bits_per_key: c_int) -> DBFilterPolicy; pub fn rocksdb_filterpolicy_create_bloom(bits_per_key: c_int) diff --git a/src/rocksdb_options.rs b/src/rocksdb_options.rs index c6112cb..9cdfc87 100644 --- a/src/rocksdb_options.rs +++ b/src/rocksdb_options.rs @@ -372,6 +372,19 @@ impl Options { rocksdb_ffi::rocksdb_options_set_wal_recovery_mode(self.inner, mode); } } + + pub fn enable_statistics(&mut self) { + unsafe { + rocksdb_ffi::rocksdb_options_enable_statistics(self.inner); + } + } + + pub fn set_stats_dump_period_sec(&mut self, period: usize) { + unsafe { + rocksdb_ffi::rocksdb_options_set_stats_dump_period_sec(self.inner, + period); + } + } } impl Default for Options { @@ -429,4 +442,11 @@ mod tests { let size = 20 * 1024 * 1024; opts.set_max_manifest_file_size(size) } + + #[test] + fn test_enable_statistics() { + let mut opts = Options::default(); + opts.enable_statistics(); + opts.set_stats_dump_period_sec(60); + } }