Fix issue where DELETE always returns 1 when using FLASH
Former-commit-id: 0574db59fdc740255388ae77d2ece8622898bb49
This commit is contained in:
parent
8c27dc6632
commit
232cc7c566
@ -22,7 +22,7 @@ public:
|
|||||||
virtual void retrieve(const char *key, size_t cchKey, callbackSingle fn) const = 0;
|
virtual void retrieve(const char *key, size_t cchKey, callbackSingle fn) const = 0;
|
||||||
virtual size_t clear() = 0;
|
virtual size_t clear() = 0;
|
||||||
virtual bool enumerate(callback fn) const = 0;
|
virtual bool enumerate(callback fn) const = 0;
|
||||||
virtual size_t count() const = 0;
|
virtual size_t count(bool fStrict) const = 0;
|
||||||
|
|
||||||
virtual void beginWriteBatch() {} // NOP
|
virtual void beginWriteBatch() {} // NOP
|
||||||
virtual void endWriteBatch() {} // NOP
|
virtual void endWriteBatch() {} // NOP
|
||||||
|
@ -2195,7 +2195,7 @@ dict_iter redisDbPersistentData::random()
|
|||||||
size_t redisDbPersistentData::size() const
|
size_t redisDbPersistentData::size() const
|
||||||
{
|
{
|
||||||
if (m_spstorage != nullptr)
|
if (m_spstorage != nullptr)
|
||||||
return m_spstorage->count();
|
return m_spstorage->count(false);
|
||||||
|
|
||||||
return dictSize(m_pdict)
|
return dictSize(m_pdict)
|
||||||
+ (m_pdbSnapshot ? (m_pdbSnapshot->size() - dictSize(m_pdictTombstone)) : 0);
|
+ (m_pdbSnapshot ? (m_pdbSnapshot->size() - dictSize(m_pdictTombstone)) : 0);
|
||||||
|
@ -24,9 +24,16 @@ bool RocksDBStorageProvider::erase(const char *key, size_t cchKey)
|
|||||||
{
|
{
|
||||||
rocksdb::Status status;
|
rocksdb::Status status;
|
||||||
if (m_spbatch != nullptr)
|
if (m_spbatch != nullptr)
|
||||||
|
{
|
||||||
status = m_spbatch->Delete(m_spcolfamily.get(), rocksdb::Slice(key, cchKey));
|
status = m_spbatch->Delete(m_spcolfamily.get(), rocksdb::Slice(key, cchKey));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
std::string strT;
|
||||||
|
if (!m_spdb->KeyMayExist(ReadOptions(), m_spcolfamily.get(), rocksdb::Slice(key, cchKey), &strT))
|
||||||
|
return false;
|
||||||
status = m_spdb->Delete(WriteOptions(), m_spcolfamily.get(), rocksdb::Slice(key, cchKey));
|
status = m_spdb->Delete(WriteOptions(), m_spcolfamily.get(), rocksdb::Slice(key, cchKey));
|
||||||
|
}
|
||||||
return status.ok();
|
return status.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +47,7 @@ void RocksDBStorageProvider::retrieve(const char *key, size_t cchKey, callbackSi
|
|||||||
|
|
||||||
size_t RocksDBStorageProvider::clear()
|
size_t RocksDBStorageProvider::clear()
|
||||||
{
|
{
|
||||||
size_t celem = count();
|
size_t celem = count(false);
|
||||||
auto status = m_spdb->DropColumnFamily(m_spcolfamily.get());
|
auto status = m_spdb->DropColumnFamily(m_spcolfamily.get());
|
||||||
auto strName = m_spcolfamily->GetName();
|
auto strName = m_spcolfamily->GetName();
|
||||||
|
|
||||||
@ -53,7 +60,18 @@ size_t RocksDBStorageProvider::clear()
|
|||||||
return celem;
|
return celem;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t RocksDBStorageProvider::count() const
|
size_t RocksDBStorageProvider::count(bool fStrict) const
|
||||||
|
{
|
||||||
|
size_t count = 0;
|
||||||
|
|
||||||
|
if (fStrict)
|
||||||
|
{
|
||||||
|
std::unique_ptr<rocksdb::Iterator> it = std::unique_ptr<rocksdb::Iterator>(m_spdb->NewIterator(ReadOptions(), m_spcolfamily.get()));
|
||||||
|
for (it->SeekToFirst(); it->Valid(); it->Next()) {
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
std::string strelem;
|
std::string strelem;
|
||||||
if (!m_spdb->GetProperty(m_spcolfamily.get(), rocksdb::DB::Properties::kEstimateNumKeys, &strelem))
|
if (!m_spdb->GetProperty(m_spcolfamily.get(), rocksdb::DB::Properties::kEstimateNumKeys, &strelem))
|
||||||
@ -61,6 +79,7 @@ size_t RocksDBStorageProvider::count() const
|
|||||||
std::stringstream sstream(strelem);
|
std::stringstream sstream(strelem);
|
||||||
size_t count;
|
size_t count;
|
||||||
sstream >> count;
|
sstream >> count;
|
||||||
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
|
|
||||||
virtual void flush() override;
|
virtual void flush() override;
|
||||||
|
|
||||||
size_t count() const;
|
size_t count(bool fStrict) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user