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;
|
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)
|
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)
|
: m_spdb(spdb), m_psnapshot(psnapshot), m_spcolfamily(spcolfam), m_count(count)
|
||||||
{
|
{
|
||||||
@ -75,16 +85,6 @@ size_t RocksDBStorageProvider::count() const
|
|||||||
return m_count;
|
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
|
bool RocksDBStorageProvider::enumerate(callback fn) const
|
||||||
{
|
{
|
||||||
std::unique_ptr<rocksdb::Iterator> it = std::unique_ptr<rocksdb::Iterator>(m_spdb->NewIterator(ReadOptions(), m_spcolfamily.get()));
|
std::unique_ptr<rocksdb::Iterator> it = std::unique_ptr<rocksdb::Iterator>(m_spdb->NewIterator(ReadOptions(), m_spcolfamily.get()));
|
||||||
|
@ -40,8 +40,9 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool FKeyExists(const char *key, size_t cchKey) const;
|
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; }
|
const rocksdb::ReadOptions &ReadOptions() const { return m_readOptionsTemplate; }
|
||||||
rocksdb::WriteOptions WriteOptions() const;
|
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");
|
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()));
|
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()) {
|
for (it->SeekToFirst(); it->Valid(); it->Next()) {
|
||||||
|
if (FInternalKey(it->key().data(), it->key().size()))
|
||||||
|
continue;
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user