Fix incorrect count when loading FLASH
Former-commit-id: 38ee9c0df144621f7ca750527e9efb16e754ef40
This commit is contained in:
parent
82e1ed482a
commit
0381e728ab
@ -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<rocksdb::DB> &spdb, std::shared_ptr<rocksdb::ColumnFamilyHandle> &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<rocksdb::Iterator> it = std::unique_ptr<rocksdb::Iterator>(m_spdb->NewIterator(ReadOptions(), m_spcolfamily.get()));
|
||||
|
@ -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;
|
||||
};
|
||||
};
|
||||
|
||||
bool FInternalKey(const char *key, size_t cch);
|
@ -120,6 +120,8 @@ IStorage *RocksDBStorageFactory::create(int db)
|
||||
printf("\tDatabase was not shutdown cleanly, recomputing metrics\n");
|
||||
std::unique_ptr<rocksdb::Iterator> it = std::unique_ptr<rocksdb::Iterator>(m_spdb->NewIterator(rocksdb::ReadOptions(), spcolfamily.get()));
|
||||
for (it->SeekToFirst(); it->Valid(); it->Next()) {
|
||||
if (FInternalKey(it->key().data(), it->key().size()))
|
||||
continue;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user