diff --git a/src/storage/rocksdb.cpp b/src/storage/rocksdb.cpp index dd88a86a8..cb0bb11a2 100644 --- a/src/storage/rocksdb.cpp +++ b/src/storage/rocksdb.cpp @@ -3,6 +3,8 @@ #include #include +static const char *keyprefix = INTERNAL_KEY_PREFIX; + 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) { @@ -73,11 +75,23 @@ 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())); size_t count = 0; for (it->SeekToFirst(); it->Valid(); it->Next()) { + if (FInternalKey(it->key().data(), it->key().size())) + continue; ++count; bool fContinue = fn(it->key().data(), it->key().size(), it->value().data(), it->value().size()); if (!fContinue) diff --git a/src/storage/rocksdb.h b/src/storage/rocksdb.h index 21e57db92..dd44c2df6 100644 --- a/src/storage/rocksdb.h +++ b/src/storage/rocksdb.h @@ -5,8 +5,9 @@ #include #include "../fastlock.h" -static const char count_key[] = "\0__keydb__count\1"; -static const char version_key[] = "\0__keydb__version\1"; +#define INTERNAL_KEY_PREFIX "\x00\x04\x03\x00\x05\x02\x04" +static const char count_key[] = INTERNAL_KEY_PREFIX "__keydb__count\1"; +static const char version_key[] = INTERNAL_KEY_PREFIX "__keydb__version\1"; class RocksDBStorageProvider : public IStorage { @@ -39,6 +40,7 @@ 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;