An public api to fetch the latest transaction id.
Summary: Implement a interface to retrieve the most current transaction id from the database. Test Plan: Added unit test. Reviewers: sheki Reviewed By: sheki CC: leveldb Differential Revision: https://reviews.facebook.net/D7269
This commit is contained in:
parent
dcd919a0a4
commit
24fc379273
@ -877,6 +877,10 @@ Status DBImpl::Flush(const FlushOptions& options) {
|
||||
return status;
|
||||
}
|
||||
|
||||
SequenceNumber DBImpl::GetLatestSequenceNumber() {
|
||||
return versions_->LastSequence();
|
||||
}
|
||||
|
||||
Status DBImpl::GetUpdatesSince(SequenceNumber seq,
|
||||
TransactionLogIterator** iter) {
|
||||
|
||||
|
@ -55,6 +55,7 @@ class DBImpl : public DB {
|
||||
virtual Status EnableFileDeletions();
|
||||
virtual Status GetLiveFiles(std::vector<std::string>&,
|
||||
uint64_t* manifest_file_size);
|
||||
virtual SequenceNumber GetLatestSequenceNumber();
|
||||
virtual Status GetUpdatesSince(SequenceNumber seq_number,
|
||||
TransactionLogIterator ** iter);
|
||||
|
||||
|
@ -2273,6 +2273,7 @@ TEST(DBTest, TransactionLogIterator) {
|
||||
Put("key1", value);
|
||||
Put("key2", value);
|
||||
Put("key2", value);
|
||||
ASSERT_EQ(dbfull()->GetLatestSequenceNumber(), 3U);
|
||||
{
|
||||
TransactionLogIterator* iter;
|
||||
Status status = dbfull()->GetUpdatesSince(0, &iter);
|
||||
@ -2583,6 +2584,9 @@ class ModelDB: public DB {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
virtual SequenceNumber GetLatestSequenceNumber() {
|
||||
return 0;
|
||||
}
|
||||
virtual Status GetUpdatesSince(leveldb::SequenceNumber,
|
||||
leveldb::TransactionLogIterator**) {
|
||||
return Status::NotSupported("Not supported in Model DB");
|
||||
|
@ -182,6 +182,9 @@ class DB {
|
||||
virtual Status GetLiveFiles(std::vector<std::string>&,
|
||||
uint64_t* manifest_file_size) = 0;
|
||||
|
||||
// The sequence number of the most recent transaction.
|
||||
virtual SequenceNumber GetLatestSequenceNumber() = 0;
|
||||
|
||||
// Return's an iterator for all writes since the sequence number
|
||||
// Status::ok if iterator is valid.
|
||||
// The iterator internally holds references to the available log files.
|
||||
|
Loading…
Reference in New Issue
Block a user