diff --git a/db/db_properties_test.cc b/db/db_properties_test.cc index 5af94569f..dbfdac970 100644 --- a/db/db_properties_test.cc +++ b/db/db_properties_test.cc @@ -90,6 +90,18 @@ TEST_F(DBPropertiesTest, Empty) { } while (ChangeOptions()); } +TEST_F(DBPropertiesTest, CurrentVersionNumber) { + uint64_t v1, v2, v3; + ASSERT_TRUE(dbfull()->GetIntProperty("rocksdb.current_version_number", &v1)); + Put("12345678", ""); + ASSERT_TRUE(dbfull()->GetIntProperty("rocksdb.current_version_number", &v2)); + Flush(); + ASSERT_TRUE(dbfull()->GetIntProperty("rocksdb.current_version_number", &v3)); + + ASSERT_EQ(v1, v2); + ASSERT_GT(v3, v2); +} + TEST_F(DBPropertiesTest, GetAggregatedIntPropertyTest) { const int kKeySize = 100; const int kValueSize = 500; diff --git a/db/internal_stats.cc b/db/internal_stats.cc index 1ec795c9c..4fa38bb1f 100644 --- a/db/internal_stats.cc +++ b/db/internal_stats.cc @@ -132,6 +132,7 @@ static const std::string is_file_deletions_enabled = static const std::string num_snapshots = "num-snapshots"; static const std::string oldest_snapshot_time = "oldest-snapshot-time"; static const std::string num_live_versions = "num-live-versions"; +static const std::string current_version_number = "current_version_number"; static const std::string estimate_live_data_size = "estimate-live-data-size"; static const std::string base_level = "base-level"; static const std::string total_sst_files_size = "total-sst-files-size"; @@ -191,6 +192,8 @@ const std::string DB::Properties::kOldestSnapshotTime = rocksdb_prefix + oldest_snapshot_time; const std::string DB::Properties::kNumLiveVersions = rocksdb_prefix + num_live_versions; +const std::string DB::Properties::kCurrentVersionNumber = + rocksdb_prefix + current_version_number; const std::string DB::Properties::kEstimateLiveDataSize = rocksdb_prefix + estimate_live_data_size; const std::string DB::Properties::kTotalSstFilesSize = @@ -254,6 +257,8 @@ const std::unordered_mapGetSuperVersionNumber(); + return true; +} + bool InternalStats::HandleIsFileDeletionsEnabled(uint64_t* value, DBImpl* db, Version* version) { *value = db->IsFileDeletionsEnabled(); diff --git a/db/internal_stats.h b/db/internal_stats.h index 958731a58..3d5580228 100644 --- a/db/internal_stats.h +++ b/db/internal_stats.h @@ -328,6 +328,8 @@ class InternalStats { bool HandleNumSnapshots(uint64_t* value, DBImpl* db, Version* version); bool HandleOldestSnapshotTime(uint64_t* value, DBImpl* db, Version* version); bool HandleNumLiveVersions(uint64_t* value, DBImpl* db, Version* version); + bool HandleCurrentVersionNumber(uint64_t* value, DBImpl* db, + Version* version); bool HandleIsFileDeletionsEnabled(uint64_t* value, DBImpl* db, Version* version); bool HandleBaseLevel(uint64_t* value, DBImpl* db, Version* version); diff --git a/include/rocksdb/db.h b/include/rocksdb/db.h index cbcb1f211..9a0022dfa 100644 --- a/include/rocksdb/db.h +++ b/include/rocksdb/db.h @@ -444,6 +444,9 @@ class DB { // by iterators or unfinished compactions. static const std::string kNumLiveVersions; + // "rocksdb.current-version-number" - returns number of curent LSM version. + static const std::string kCurrentVersionNumber; + // "rocksdb.estimate-live-data-size" - returns an estimate of the amount of // live data in bytes. static const std::string kEstimateLiveDataSize; @@ -504,6 +507,7 @@ class DB { // "rocksdb.num-snapshots" // "rocksdb.oldest-snapshot-time" // "rocksdb.num-live-versions" + // "rocksdb.current_version_number" // "rocksdb.estimate-live-data-size" // "rocksdb.total-sst-files-size" // "rocksdb.base-level"