|
|
@ -366,16 +366,14 @@ impl DB { |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn write(&self, batch: WriteBatch) -> Result<(), String> { |
|
|
|
pub fn write_opt(&self, batch: WriteBatch, writeopts: &WriteOptions) -> Result<(), String> { |
|
|
|
let writeopts = unsafe { rocksdb_ffi::rocksdb_writeoptions_create() }; |
|
|
|
|
|
|
|
let mut err: *const i8 = 0 as *const i8; |
|
|
|
let mut err: *const i8 = 0 as *const i8; |
|
|
|
let err_ptr: *mut *const i8 = &mut err; |
|
|
|
let err_ptr: *mut *const i8 = &mut err; |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
rocksdb_ffi::rocksdb_write(self.inner, |
|
|
|
rocksdb_ffi::rocksdb_write(self.inner, |
|
|
|
writeopts.clone(), |
|
|
|
writeopts.inner, |
|
|
|
batch.inner, |
|
|
|
batch.inner, |
|
|
|
err_ptr); |
|
|
|
err_ptr); |
|
|
|
rocksdb_ffi::rocksdb_writeoptions_destroy(writeopts); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if !err.is_null() { |
|
|
|
if !err.is_null() { |
|
|
|
return Err(error_message(err)); |
|
|
|
return Err(error_message(err)); |
|
|
@ -383,6 +381,10 @@ impl DB { |
|
|
|
return Ok(()); |
|
|
|
return Ok(()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn write(&self, batch: WriteBatch) -> Result<(), String> { |
|
|
|
|
|
|
|
self.write_opt(batch, &WriteOptions::new()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn get(&self, key: &[u8]) -> Result<Option<DBVector>, String> { |
|
|
|
pub fn get(&self, key: &[u8]) -> Result<Option<DBVector>, String> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
let readopts = rocksdb_ffi::rocksdb_readoptions_create(); |
|
|
|
let readopts = rocksdb_ffi::rocksdb_readoptions_create(); |
|
|
|