MCPcopy Create free account
hub / github.com/apache/kvrocks / IsEmptyDB

Method IsEmptyDB

src/storage/storage.cc:556–567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

554}
555
556bool Storage::IsEmptyDB() {
557 std::unique_ptr<rocksdb::Iterator> iter(
558 db_->NewIterator(DefaultScanOptions(), GetCFHandle(ColumnFamilyID::Metadata)));
559 for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
560 Metadata metadata(kRedisNone, false);
561 // If cannot decode the metadata we think the key is alive, so the db is not empty
562 if (!metadata.Decode(iter->value()).ok() || !metadata.Expired()) {
563 return false;
564 }
565 }
566 return true;
567}
568
569void Storage::EmptyDB() {
570 // Clean old backups and checkpoints

Callers 1

ResetMethod · 0.80

Calls 5

NewIteratorMethod · 0.80
ExpiredMethod · 0.80
ValidMethod · 0.45
NextMethod · 0.45
DecodeMethod · 0.45

Tested by

no test coverage detected