Commit 8e198679 authored by Jay's avatar Jay Committed by GitHub

make code more rusty (#41)

parent 37e70775
This diff is collapsed.
...@@ -24,9 +24,9 @@ pub mod rocksdb_options; ...@@ -24,9 +24,9 @@ pub mod rocksdb_options;
pub mod merge_operator; pub mod merge_operator;
pub mod comparator; pub mod comparator;
pub use librocksdb_sys::{DBCompactionStyle, DBComparator, DBCompressionType, pub use librocksdb_sys::{DBCompactionStyle, DBCompressionType,
DBRecoveryMode, new_bloom_filter, self as rocksdb_ffi}; DBRecoveryMode, new_bloom_filter, self as rocksdb_ffi};
pub use merge_operator::MergeOperands; pub use merge_operator::MergeOperands;
pub use rocksdb::{DB, DBIterator, DBVector, Kv, SeekKey, Writable, WriteBatch}; pub use rocksdb::{DB, DBIterator, DBVector, Kv, SeekKey, Writable, WriteBatch, CFHandle};
pub use rocksdb_options::{BlockBasedOptions, Options, ReadOptions, pub use rocksdb_options::{BlockBasedOptions, Options, ReadOptions,
WriteOptions}; WriteOptions};
...@@ -143,7 +143,7 @@ fn main() { ...@@ -143,7 +143,7 @@ fn main() {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use rocksdb::{BlockBasedOptions, DB, DBCompressionType, Options, ReadOptions, WriteOptions, SeekKey}; use rocksdb::{BlockBasedOptions, DB, DBCompressionType, Options};
use rocksdb::DBCompactionStyle::DBUniversal; use rocksdb::DBCompactionStyle::DBUniversal;
use rocksdb::DBRecoveryMode; use rocksdb::DBRecoveryMode;
......
This diff is collapsed.
...@@ -20,7 +20,7 @@ use merge_operator::{self, MergeOperatorCallback, full_merge_callback, ...@@ -20,7 +20,7 @@ use merge_operator::{self, MergeOperatorCallback, full_merge_callback,
use merge_operator::MergeFn; use merge_operator::MergeFn;
use rocksdb_ffi::{self, DBOptions, DBWriteOptions, DBBlockBasedTableOptions, use rocksdb_ffi::{self, DBOptions, DBWriteOptions, DBBlockBasedTableOptions,
DBReadOptions, DBCompressionType, DBRecoveryMode}; DBReadOptions, DBCompressionType, DBRecoveryMode, DBSnapshot, DBInstance};
use std::ffi::CString; use std::ffi::CString;
use std::mem; use std::mem;
...@@ -97,15 +97,15 @@ impl BlockBasedOptions { ...@@ -97,15 +97,15 @@ impl BlockBasedOptions {
/// This object is convenient for wrapping snapshot by yourself. In most /// This object is convenient for wrapping snapshot by yourself. In most
/// cases, using `Snapshot` is enough. /// cases, using `Snapshot` is enough.
pub struct UnsafeSnap { pub struct UnsafeSnap {
inner: rocksdb_ffi::DBSnapshot, inner: *const DBSnapshot,
} }
impl UnsafeSnap { impl UnsafeSnap {
pub unsafe fn new(db: rocksdb_ffi::DBInstance) -> UnsafeSnap { pub unsafe fn new(db: *mut DBInstance) -> UnsafeSnap {
UnsafeSnap { inner: rocksdb_ffi::rocksdb_create_snapshot(db) } UnsafeSnap { inner: rocksdb_ffi::rocksdb_create_snapshot(db) }
} }
pub unsafe fn get_inner(&self) -> rocksdb_ffi::DBSnapshot { pub unsafe fn get_inner(&self) -> *const DBSnapshot {
self.inner self.inner
} }
} }
......
...@@ -73,7 +73,7 @@ pub fn test_column_family() { ...@@ -73,7 +73,7 @@ pub fn test_column_family() {
} }
Err(e) => panic!("failed to open db with column family: {}", e), Err(e) => panic!("failed to open db with column family: {}", e),
}; };
let cf1 = *db.cf_handle("cf1").unwrap(); let cf1 = db.cf_handle("cf1").unwrap();
assert!(db.put_cf(cf1, b"k1", b"v1").is_ok()); assert!(db.put_cf(cf1, b"k1", b"v1").is_ok());
assert!(db.get_cf(cf1, b"k1").unwrap().unwrap().to_utf8().unwrap() == assert!(db.get_cf(cf1, b"k1").unwrap().unwrap().to_utf8().unwrap() ==
"v1"); "v1");
......
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