Commit 87f2aa24 authored by zhangjinpeng1987's avatar zhangjinpeng1987 Committed by Jay

enable statistics (#42)

parent 8e198679
......@@ -181,6 +181,8 @@ extern "C" {
v: c_int);
pub fn rocksdb_options_set_report_bg_io_stats(options: *mut DBOptions, v: c_int);
pub fn rocksdb_options_set_wal_recovery_mode(options: *mut DBOptions, mode: DBRecoveryMode);
pub fn rocksdb_options_enable_statistics(options: *mut DBOptions);
pub fn rocksdb_options_set_stats_dump_period_sec(options: *mut DBOptions, v: usize);
pub fn rocksdb_filterpolicy_create_bloom_full(bits_per_key: c_int)
-> *mut DBFilterPolicy;
pub fn rocksdb_filterpolicy_create_bloom(bits_per_key: c_int)
......
......@@ -181,6 +181,8 @@ mod tests {
opts.set_filter_deletes(false);
opts.set_report_bg_io_stats(true);
opts.set_wal_recovery_mode(DBRecoveryMode::PointInTime);
opts.enable_statistics();
opts.set_stats_dump_period_sec(60);
opts.compression_per_level(&per_level_compression);
blockopts.set_block_size(524288);
blockopts.set_cache_index_and_filter_blocks(true);
......
......@@ -555,7 +555,7 @@ impl DB {
opts.inner,
cname_ptr,
&mut err);
if !err.is_null() {
return Err(error_message(err));
}
......
......@@ -505,6 +505,19 @@ impl Options {
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);
}
}
}
#[cfg(test)]
......@@ -517,4 +530,11 @@ mod tests {
let size = 20 * 1024 * 1024;
opts.set_max_manifest_file_size(size)
}
#[test]
fn test_enable_statistics() {
let mut opts = Options::new();
opts.enable_statistics();
opts.set_stats_dump_period_sec(60);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment