Commit 30463dab authored by zhangjinpeng1987's avatar zhangjinpeng1987

address comments

parent 02604f2f
...@@ -205,7 +205,7 @@ mod tests { ...@@ -205,7 +205,7 @@ mod tests {
db.put_opt(b"k2-0", b"c", &writeopts).unwrap(); db.put_opt(b"k2-0", b"c", &writeopts).unwrap();
let mut readopts = ReadOptions::new(); let mut readopts = ReadOptions::new();
readopts.set_iterate_upper_bound("k2"); readopts.set_iterate_upper_bound(b"k2");
let mut iter = db.iter_opt(readopts); let mut iter = db.iter_opt(readopts);
iter.seek(SeekKey::Start); iter.seek(SeekKey::Start);
let mut count = 0; let mut count = 0;
......
...@@ -42,7 +42,7 @@ pub struct WriteBatch { ...@@ -42,7 +42,7 @@ pub struct WriteBatch {
pub struct ReadOptions { pub struct ReadOptions {
inner: rocksdb_ffi::DBReadOptions, inner: rocksdb_ffi::DBReadOptions,
upper_bound: String, upper_bound: Vec<u8>,
} }
/// The UnsafeSnap must be destroyed by db, it maybe be leaked /// The UnsafeSnap must be destroyed by db, it maybe be leaked
...@@ -1062,7 +1062,7 @@ impl Drop for ReadOptions { ...@@ -1062,7 +1062,7 @@ impl Drop for ReadOptions {
impl Default for ReadOptions { impl Default for ReadOptions {
fn default() -> ReadOptions { fn default() -> ReadOptions {
unsafe { unsafe {
ReadOptions { inner: rocksdb_ffi::rocksdb_readoptions_create(), upper_bound: String::new() } ReadOptions { inner: rocksdb_ffi::rocksdb_readoptions_create(), upper_bound: vec![] }
} }
} }
} }
...@@ -1086,8 +1086,8 @@ impl ReadOptions { ...@@ -1086,8 +1086,8 @@ impl ReadOptions {
snapshot.inner); snapshot.inner);
} }
pub fn set_iterate_upper_bound(&mut self, key: &str) { pub fn set_iterate_upper_bound(&mut self, key: &[u8]) {
self.upper_bound = String::from(key); self.upper_bound = Vec::from(key);
unsafe { unsafe {
rocksdb_ffi::rocksdb_readoptions_set_iterate_upper_bound(self.inner, rocksdb_ffi::rocksdb_readoptions_set_iterate_upper_bound(self.inner,
self.upper_bound.as_ptr(), self.upper_bound.as_ptr(),
......
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