From 0381e728ab997bd6bf2e26506d411e1ed321c16e Mon Sep 17 00:00:00 2001 From: John Sully Date: Mon, 23 Mar 2020 19:47:48 -0400 Subject: [PATCH] Fix incorrect count when loading FLASH Former-commit-id: 38ee9c0df144621f7ca750527e9efb16e754ef40 --- src/storage/rocksdb.cpp | 20 ++++++++++---------- src/storage/rocksdb.h | 5 +++-- src/storage/rocksdbfactory.cpp | 2 ++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/storage/rocksdb.cpp b/src/storage/rocksdb.cpp index cb0bb11a2..76acfd62e 100644 --- a/src/storage/rocksdb.cpp +++ b/src/storage/rocksdb.cpp @@ -5,6 +5,16 @@ static const char *keyprefix = INTERNAL_KEY_PREFIX; +bool FInternalKey(const char *key, size_t cch) +{ + if (cch > strlen(INTERNAL_KEY_PREFIX)) + { + if (memcmp(key, keyprefix, strlen(INTERNAL_KEY_PREFIX)) == 0) + return true; + } + return false; +} + RocksDBStorageProvider::RocksDBStorageProvider(std::shared_ptr &spdb, std::shared_ptr &spcolfam, const rocksdb::Snapshot *psnapshot, size_t count) : m_spdb(spdb), m_psnapshot(psnapshot), m_spcolfamily(spcolfam), m_count(count) { @@ -75,16 +85,6 @@ size_t RocksDBStorageProvider::count() const return m_count; } -bool RocksDBStorageProvider::FInternalKey(const char *key, size_t cch) const -{ - if (cch > strlen(INTERNAL_KEY_PREFIX)) - { - if (memcmp(key, keyprefix, strlen(INTERNAL_KEY_PREFIX)) == 0) - return true; - } - return false; -} - bool RocksDBStorageProvider::enumerate(callback fn) const { std::unique_ptr it = std::unique_ptr(m_spdb->NewIterator(ReadOptions(), m_spcolfamily.get())); diff --git a/src/storage/rocksdb.h b/src/storage/rocksdb.h index dd44c2df6..5f9261288 100644 --- a/src/storage/rocksdb.h +++ b/src/storage/rocksdb.h @@ -40,8 +40,9 @@ public: protected: bool FKeyExists(const char *key, size_t cchKey) const; - bool FInternalKey(const char *key, size_t cchKey) const; const rocksdb::ReadOptions &ReadOptions() const { return m_readOptionsTemplate; } rocksdb::WriteOptions WriteOptions() const; -}; \ No newline at end of file +}; + +bool FInternalKey(const char *key, size_t cch); \ No newline at end of file diff --git a/src/storage/rocksdbfactory.cpp b/src/storage/rocksdbfactory.cpp index f02701130..ca4d86c23 100644 --- a/src/storage/rocksdbfactory.cpp +++ b/src/storage/rocksdbfactory.cpp @@ -120,6 +120,8 @@ IStorage *RocksDBStorageFactory::create(int db) printf("\tDatabase was not shutdown cleanly, recomputing metrics\n"); std::unique_ptr it = std::unique_ptr(m_spdb->NewIterator(rocksdb::ReadOptions(), spcolfamily.get())); for (it->SeekToFirst(); it->Valid(); it->Next()) { + if (FInternalKey(it->key().data(), it->key().size())) + continue; ++count; } }