Skip to content

Commit 72a6b68

Browse files
authored
update rocksdb and add largest_seqno to MemtableInfo (#723)
* update rocksdb Signed-off-by: 5kbpers <[email protected]>
1 parent bd07e9e commit 72a6b68

File tree

6 files changed

+23
-1
lines changed

6 files changed

+23
-1
lines changed

librocksdb_sys/crocksdb/c.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,6 +2353,10 @@ uint64_t crocksdb_memtableinfo_earliest_seqno(
23532353
const crocksdb_memtableinfo_t* info) {
23542354
return info->rep.earliest_seqno;
23552355
}
2356+
uint64_t crocksdb_memtableinfo_largest_seqno(
2357+
const crocksdb_memtableinfo_t* info) {
2358+
return info->rep.largest_seqno;
2359+
}
23562360
uint64_t crocksdb_memtableinfo_num_entries(
23572361
const crocksdb_memtableinfo_t* info) {
23582362
return info->rep.num_entries;

librocksdb_sys/crocksdb/crocksdb/c.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,8 @@ crocksdb_memtableinfo_first_seqno(const crocksdb_memtableinfo_t*);
934934
extern C_ROCKSDB_LIBRARY_API uint64_t
935935
crocksdb_memtableinfo_earliest_seqno(const crocksdb_memtableinfo_t*);
936936
extern C_ROCKSDB_LIBRARY_API uint64_t
937+
crocksdb_memtableinfo_largest_seqno(const crocksdb_memtableinfo_t*);
938+
extern C_ROCKSDB_LIBRARY_API uint64_t
937939
crocksdb_memtableinfo_num_entries(const crocksdb_memtableinfo_t*);
938940
extern C_ROCKSDB_LIBRARY_API uint64_t
939941
crocksdb_memtableinfo_num_deletes(const crocksdb_memtableinfo_t*);

librocksdb_sys/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,6 +2299,7 @@ extern "C" {
22992299
) -> *const c_char;
23002300
pub fn crocksdb_memtableinfo_first_seqno(info: *const DBMemTableInfo) -> u64;
23012301
pub fn crocksdb_memtableinfo_earliest_seqno(info: *const DBMemTableInfo) -> u64;
2302+
pub fn crocksdb_memtableinfo_largest_seqno(info: *const DBMemTableInfo) -> u64;
23022303
pub fn crocksdb_memtableinfo_num_entries(info: *const DBMemTableInfo) -> u64;
23032304
pub fn crocksdb_memtableinfo_num_deletes(info: *const DBMemTableInfo) -> u64;
23042305

src/event_listener.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ impl MemTableInfo {
243243
pub fn earliest_seqno(&self) -> u64 {
244244
unsafe { crocksdb_ffi::crocksdb_memtableinfo_earliest_seqno(&self.0) }
245245
}
246+
pub fn largest_seqno(&self) -> u64 {
247+
unsafe { crocksdb_ffi::crocksdb_memtableinfo_largest_seqno(&self.0) }
248+
}
246249
pub fn num_entries(&self) -> u64 {
247250
unsafe { crocksdb_ffi::crocksdb_memtableinfo_num_entries(&self.0) }
248251
}

tests/cases/test_event_listener.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ impl Drop for EventCounter {
4141
}
4242

4343
impl EventListener for EventCounter {
44+
fn on_memtable_sealed(&self, info: &MemTableInfo) {
45+
assert!(!info.cf_name().is_empty());
46+
assert_ne!(info.largest_seqno(), 0);
47+
assert!(info.earliest_seqno() <= info.largest_seqno());
48+
}
49+
50+
fn on_flush_begin(&self, info: &FlushJobInfo) {
51+
assert!(!info.cf_name().is_empty());
52+
assert_ne!(info.largest_seqno(), 0);
53+
assert!(info.smallest_seqno() <= info.largest_seqno());
54+
}
55+
4456
fn on_flush_completed(&self, info: &FlushJobInfo) {
4557
assert!(!info.cf_name().is_empty());
4658
assert!(info.file_path().exists());

0 commit comments

Comments
 (0)