From 6c6037f60cfc1b4c2bc59391eddefaf3c766b8b7 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Thu, 29 Jan 2015 18:22:43 -0800 Subject: [PATCH] Expose Snapshot's SequenceNumber Summary: Requested here: https://www.facebook.com/groups/rocksdb.dev/permalink/705524519546065/ It might also help with mongo. I don't see a reason why we shouldn't expose this info. Test Plan: make check Reviewers: sdong, yhchiang, rven Reviewed By: rven Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D32547 --- db/db_test.cc | 6 ++++++ db/snapshot.h | 2 ++ include/rocksdb/db.h | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/db/db_test.cc b/db/db_test.cc index a8973a102..5941dc2d2 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -7751,6 +7751,12 @@ class ModelDB: public DB { class ModelSnapshot : public Snapshot { public: KVMap map_; + + virtual SequenceNumber GetSequenceNumber() const { + // no need to call this + assert(false); + return 0; + } }; explicit ModelDB(const Options& options) : options_(options) {} diff --git a/db/snapshot.h b/db/snapshot.h index 45c66eabc..de9897f24 100644 --- a/db/snapshot.h +++ b/db/snapshot.h @@ -20,6 +20,8 @@ class SnapshotImpl : public Snapshot { public: SequenceNumber number_; // const after creation + virtual SequenceNumber GetSequenceNumber() const { return number_; } + private: friend class SnapshotList; diff --git a/include/rocksdb/db.h b/include/rocksdb/db.h index a519db7f6..a4141f38b 100644 --- a/include/rocksdb/db.h +++ b/include/rocksdb/db.h @@ -64,6 +64,10 @@ static const int kMinorVersion = __ROCKSDB_MINOR__; // A Snapshot is an immutable object and can therefore be safely // accessed from multiple threads without any external synchronization. class Snapshot { + public: + // returns Snapshot's sequence number + virtual SequenceNumber GetSequenceNumber() const = 0; + protected: virtual ~Snapshot(); };