Start adding WriteOptions.

master
Ceri Storey 9 years ago
parent 2dc9568b50
commit c1c067f1f4
  1. 2
      src/ffi.rs
  2. 28
      src/rocksdb_options.rs

@ -190,6 +190,8 @@ extern {
-> DBInstance;
pub fn rocksdb_writeoptions_create() -> DBWriteOptions;
pub fn rocksdb_writeoptions_destroy(writeopts: DBWriteOptions);
pub fn rocksdb_writeoptions_set_sync(writeopts: DBWriteOptions, v: bool);
pub fn rocksdb_writeoptions_disable_WAL(writeopts: DBWriteOptions, v: c_int);
pub fn rocksdb_put(db: DBInstance,
writeopts: DBWriteOptions,
k: *const u8,

@ -31,6 +31,10 @@ pub struct Options {
pub inner: rocksdb_ffi::DBOptions,
}
pub struct WriteOptions {
pub inner: rocksdb_ffi::DBWriteOptions,
}
impl Drop for Options {
fn drop(&mut self) {
unsafe {
@ -47,6 +51,14 @@ impl Drop for BlockBasedOptions {
}
}
impl Drop for WriteOptions {
fn drop(&mut self) {
unsafe {
rocksdb_ffi::rocksdb_writeoptions_destroy(self.inner);
}
}
}
impl BlockBasedOptions {
pub fn new() -> BlockBasedOptions {
let block_opts = unsafe {
@ -311,3 +323,19 @@ impl Options {
}
}
}
impl WriteOptions {
pub fn new() -> WriteOptions {
let write_opts = unsafe { rocksdb_ffi::rocksdb_writeoptions_create() };
let rocksdb_ffi::DBWriteOptions(opt_ptr) = write_opts;
if opt_ptr.is_null() {
panic!("Could not create rocksdb write options".to_string());
}
WriteOptions { inner: write_opts }
}
pub fn set_sync(&mut self, sync: bool) {
unsafe {
rocksdb_ffi::rocksdb_writeoptions_set_sync(self.inner, sync);
}
}
}

Loading…
Cancel
Save