|
|
@ -106,6 +106,20 @@ impl DBIterator { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn new_cf(db: &RocksDB, cf_name: &str, readopts: &ReadOptions) -> Result<DBIterator, String> { |
|
|
|
|
|
|
|
let cf = db.cfs.get(cf_name); |
|
|
|
|
|
|
|
if cf.is_none() { |
|
|
|
|
|
|
|
return Err(format!("Invalid column family: {}", cf_name).to_string()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
unsafe { |
|
|
|
|
|
|
|
let iterator = rocksdb_ffi::rocksdb_create_iterator_cf(db.inner, |
|
|
|
|
|
|
|
readopts.inner, |
|
|
|
|
|
|
|
*cf.unwrap()); |
|
|
|
|
|
|
|
rocksdb_ffi::rocksdb_iter_seek_to_first(iterator); |
|
|
|
|
|
|
|
Ok(DBIterator{ inner: iterator, direction: Direction::forward, just_seeked: true }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn from_start(&mut self) -> SubDBIterator { |
|
|
|
pub fn from_start(&mut self) -> SubDBIterator { |
|
|
|
self.just_seeked = true; |
|
|
|
self.just_seeked = true; |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
@ -389,6 +403,11 @@ impl RocksDB { |
|
|
|
DBIterator::new(&self, &opts) |
|
|
|
DBIterator::new(&self, &opts) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn iterator_cf(&self, cf: &str) -> Result<DBIterator, String> { |
|
|
|
|
|
|
|
let opts = ReadOptions::new(); |
|
|
|
|
|
|
|
DBIterator::new_cf(&self, cf, &opts) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn snapshot(&self) -> Snapshot { |
|
|
|
pub fn snapshot(&self) -> Snapshot { |
|
|
|
Snapshot::new(self) |
|
|
|
Snapshot::new(self) |
|
|
|
} |
|
|
|
} |
|
|
|