wal recovery mode

master
zhangjinpeng1987 8 years ago committed by Karl Hobley
parent ad09a5fbe1
commit f542987ba7
  1. 10
      src/ffi.rs
  2. 2
      src/lib.rs
  3. 8
      src/rocksdb_options.rs

@ -94,6 +94,15 @@ pub enum DBUniversalCompactionStyle {
rocksdb_total_size_compaction_stop_style = 1,
}
#[derive(Copy, Clone, PartialEq)]
#[repr(C)]
pub enum DBRecoveryMode {
TolerateCorruptedTailRecords = 0,
AbsoluteConsistency = 1,
PointInTime = 2,
SkipAnyCorruptedRecords = 3,
}
pub fn error_message(ptr: *const i8) -> String {
let c_str = unsafe { CStr::from_ptr(ptr as *const _) };
let s = from_utf8(c_str.to_bytes()).unwrap().to_owned();
@ -196,6 +205,7 @@ extern "C" {
pub fn rocksdb_options_set_disable_auto_compactions(options: DBOptions,
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_filterpolicy_create_bloom_full(bits_per_key: c_int)
-> DBFilterPolicy;
pub fn rocksdb_filterpolicy_create_bloom(bits_per_key: c_int)

@ -13,7 +13,7 @@
// limitations under the License.
//
pub use ffi as rocksdb_ffi;
pub use ffi::{DBCompactionStyle, DBComparator, DBCompressionType, new_bloom_filter};
pub use ffi::{DBCompactionStyle, DBComparator, DBCompressionType, DBRecoveryMode, new_bloom_filter};
pub use rocksdb::{DB, DBIterator, DBVector, Direction, IteratorMode, Writable,
WriteBatch};
pub use rocksdb_options::{BlockBasedOptions, Options, WriteOptions};

@ -17,7 +17,7 @@ use self::libc::{c_int,size_t};
use std::ffi::CString;
use std::mem;
use rocksdb_ffi::{self, DBCompressionType};
use rocksdb_ffi::{self, DBCompressionType, DBRecoveryMode};
use merge_operator::{self, MergeFn, MergeOperatorCallback,
full_merge_callback, partial_merge_callback};
use comparator::{self, ComparatorCallback, compare_callback};
@ -366,6 +366,12 @@ impl Options {
}
}
}
pub fn set_wal_recovery_mode(&mut self, mode: DBRecoveryMode) {
unsafe {
rocksdb_ffi::rocksdb_options_set_wal_recovery_mode(self.inner, mode);
}
}
}
impl Default for Options {

Loading…
Cancel
Save