From 2eb2710d9bfc8c9550844efc1bd438e354daf126 Mon Sep 17 00:00:00 2001 From: Tyler Neely Date: Mon, 19 Jan 2015 15:10:07 -0500 Subject: [PATCH] add some more ffi support, update README --- README.md | 7 +++---- src/ffi.rs | 33 ++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ae8ae96..2a632d6 100644 --- a/README.md +++ b/README.md @@ -116,13 +116,12 @@ fn tuned_for_somebody_elses_disk() -> RocksDB { - [x] compaction filter, style - [x] LRU cache - [x] destroy/repair - - [ ] batch - - [ ] iterator - - [ ] range - [ ] create/release snapshot + - [ ] iterator - [ ] column family operations + - [ ] write batch - [ ] comparator - [ ] slicetransform - [ ] windows support -Feedback and pull requests welcome! +Feedback and pull requests welcome! If a particular feature of RocksDB is important to you, please let me know by opening an issue, and I'll prioritize it. diff --git a/src/ffi.rs b/src/ffi.rs index 0583af7..a1bccb7 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -35,6 +35,10 @@ pub struct RocksDBCache(pub *const c_void); pub struct RocksDBFilterPolicy(pub *const c_void); #[repr(C)] pub struct RocksDBSnapshot(pub *const c_void); +#[repr(C)] +pub struct RocksDBIterator(pub *const c_void); +#[repr(C)] +pub struct RocksDBCFHandle(pub *const c_void); impl Copy for RocksDBOptions {} impl Copy for RocksDBInstance {} @@ -48,6 +52,8 @@ impl Copy for RocksDBCompactionStyle {} impl Copy for RocksDBCompressionType {} impl Copy for RocksDBUniversalCompactionStyle {} impl Copy for RocksDBSnapshot {} +impl Copy for RocksDBIterator {} +impl Copy for RocksDBCFHandle {} pub fn new_bloom_filter(bits: c_int) -> RocksDBFilterPolicy { unsafe { @@ -181,12 +187,32 @@ extern { v: *const u8, vLen: size_t, err: *mut i8); pub fn rocksdb_readoptions_create() -> RocksDBReadOptions; + pub fn rocksdb_readoptions_set_snapshot(read_opts: RocksDBReadOptions, + snapshot: RocksDBSnapshot); pub fn rocksdb_get(db: RocksDBInstance, readopts: RocksDBReadOptions, k: *const u8, kLen: size_t, valLen: *const size_t, err: *mut i8 ) -> *mut c_void; + pub fn rocksdb_get_cf(db: RocksDBInstance, + readopts: RocksDBReadOptions, + cf_handle: RocksDBCFHandle, + k: *const u8, kLen: size_t, + valLen: *const size_t, + err: *mut i8 + ) -> *mut c_void; + pub fn rocksdb_create_iterator(db: RocksDBInstance, + readopts: RocksDBReadOptions + ) -> RocksDBIterator; + pub fn rocksdb_create_iterator_cf(db: RocksDBInstance, + readopts: RocksDBReadOptions, + cf_handle: RocksDBCFHandle + ) -> RocksDBIterator; + pub fn rocksdb_create_snapshot(db: RocksDBInstance) -> RocksDBSnapshot; + pub fn rocksdb_release_snapshot(db: RocksDBInstance, + snapshot: RocksDBSnapshot); + pub fn rocksdb_delete(db: RocksDBInstance, writeopts: RocksDBWriteOptions, k: *const u8, kLen: size_t, @@ -231,13 +257,6 @@ extern { pub fn rocksdb_mergeoperator_destroy(mo: RocksDBMergeOperator); pub fn rocksdb_options_set_merge_operator(options: RocksDBOptions, mo: RocksDBMergeOperator); - // Snapshot - pub fn rocksdb_create_snapshot(db: RocksDBInstance) -> RocksDBSnapshot; - pub fn rocksdb_readoptions_set_snapshot(read_opts: RocksDBReadOptions, - snapshot: RocksDBSnapshot); - pub fn rocksdb_release_snapshot(db: RocksDBInstance, - snapshot: RocksDBSnapshot); - } #[allow(dead_code)]