Commit e4aebfd5 authored by goroutine's avatar goroutine

Merge pull request #11 from ngaut/ngaut/disable-wal

*: add an option to disable write-ahead-log.
parents 015e65bb 21793570
...@@ -41,7 +41,6 @@ pub extern "C" fn name_callback(raw_cb: *mut c_void) -> *const c_char { ...@@ -41,7 +41,6 @@ pub extern "C" fn name_callback(raw_cb: *mut c_void) -> *const c_char {
} }
} }
#[allow(too_many_arguments)]
pub extern "C" fn full_merge_callback(raw_cb: *mut c_void, pub extern "C" fn full_merge_callback(raw_cb: *mut c_void,
raw_key: *const c_char, raw_key: *const c_char,
key_len: size_t, key_len: size_t,
...@@ -75,7 +74,6 @@ pub extern "C" fn full_merge_callback(raw_cb: *mut c_void, ...@@ -75,7 +74,6 @@ pub extern "C" fn full_merge_callback(raw_cb: *mut c_void,
} }
} }
#[allow(too_many_arguments)]
pub extern "C" fn partial_merge_callback(raw_cb: *mut c_void, pub extern "C" fn partial_merge_callback(raw_cb: *mut c_void,
raw_key: *const c_char, raw_key: *const c_char,
key_len: size_t, key_len: size_t,
......
...@@ -440,6 +440,12 @@ impl DB { ...@@ -440,6 +440,12 @@ impl DB {
self.write_opt(batch, &WriteOptions::new()) self.write_opt(batch, &WriteOptions::new())
} }
pub fn write_withou_wal(&self, batch: WriteBatch) -> Result<(), String> {
let mut wo = WriteOptions::new();
wo.disable_wal(true);
self.write_opt(batch, &wo)
}
pub fn get_opt(&self, pub fn get_opt(&self,
key: &[u8], key: &[u8],
readopts: &ReadOptions) readopts: &ReadOptions)
......
...@@ -377,9 +377,20 @@ impl WriteOptions { ...@@ -377,9 +377,20 @@ impl WriteOptions {
pub fn new() -> WriteOptions { pub fn new() -> WriteOptions {
WriteOptions::default() WriteOptions::default()
} }
pub fn set_sync(&mut self, sync: bool) { pub fn set_sync(&mut self, sync: bool) {
unsafe { unsafe {
rocksdb_ffi::rocksdb_writeoptions_set_sync(self.inner, sync); rocksdb_ffi::rocksdb_writeoptions_set_sync(self.inner, sync);
} }
} }
pub fn disable_wal(&mut self, disable: bool) {
unsafe {
if disable {
rocksdb_ffi::rocksdb_writeoptions_disable_WAL(self.inner, 1);
} else {
rocksdb_ffi::rocksdb_writeoptions_disable_WAL(self.inner, 0);
}
}
}
} }
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