Add `DB::latest_sequence_number` method. (#326)

master
Ilya Bogdanov 5 years ago committed by GitHub
parent c5e8c9f5ef
commit 932a70e1f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 5
      src/db.rs
  3. 11
      tests/test_db.rs

@ -9,6 +9,7 @@
* Bumped RocksDB to 6.1.2 (lispy)
* Added `Sync` and `Send` implementations to `Snapshot` (pavel-mukhanov)
* Added `raw_iterator_cf_opt` to the DB API (rnarubin)
* Added `DB::latest_sequence_number` method (vitvakatu)
## 0.12.2 (2019-05-03)

@ -1560,6 +1560,11 @@ impl DB {
Err(e) => Err(e),
}
}
/// The sequence number of the most recent transaction.
pub fn latest_sequence_number(&self) -> u64 {
unsafe { ffi::rocksdb_get_latest_sequence_number(self.inner) }
}
}
impl WriteBatch {

@ -240,3 +240,14 @@ fn set_option_test() {
db.set_options(&multiple_options).unwrap();
}
}
#[test]
fn test_sequence_number() {
let path = DBPath::new("_rust_rocksdb_test_sequence_number");
{
let db = DB::open_default(&path).unwrap();
assert_eq!(db.latest_sequence_number(), 0);
db.put(b"key", b"value");
assert_eq!(db.latest_sequence_number(), 1);
}
}

Loading…
Cancel
Save