From 830f61ddb789bbd0775fca115ff6926c57c1777e Mon Sep 17 00:00:00 2001 From: ArcueidType <981354012@qq.com> Date: Wed, 6 Nov 2024 20:19:49 +0800 Subject: [PATCH 1/2] config kNumLevels for TEST LastLevelCompaction --- db/dbformat.h | 2 +- db/version_set.cc | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/db/dbformat.h b/db/dbformat.h index a1c30ed..6dc0ba8 100644 --- a/db/dbformat.h +++ b/db/dbformat.h @@ -22,7 +22,7 @@ namespace leveldb { // Grouping of constants. We may want to make some of these // parameters set via options. namespace config { -static const int kNumLevels = 7; +static const int kNumLevels = 3; // Level-0 compaction is started when we hit this many files. static const int kL0_CompactionTrigger = 4; diff --git a/db/version_set.cc b/db/version_set.cc index a9d80e2..b147e08 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -1104,13 +1104,11 @@ int VersionSet::NumLevelFiles(int level) const { const char* VersionSet::LevelSummary(LevelSummaryStorage* scratch) const { // Update code if kNumLevels changes - static_assert(config::kNumLevels == 7, ""); + static_assert(config::kNumLevels == 3, ""); std::snprintf( - scratch->buffer, sizeof(scratch->buffer), "files[ %d %d %d %d %d %d %d ]", + scratch->buffer, sizeof(scratch->buffer), "files[ %d %d %d ]", int(current_->files_[0].size()), int(current_->files_[1].size()), - int(current_->files_[2].size()), int(current_->files_[3].size()), - int(current_->files_[4].size()), int(current_->files_[5].size()), - int(current_->files_[6].size())); + int(current_->files_[2].size())); return scratch->buffer; } From 2481ca24baaf752c295ce01b86445370c4de880c Mon Sep 17 00:00:00 2001 From: ArcueidType <981354012@qq.com> Date: Wed, 6 Nov 2024 20:20:48 +0800 Subject: [PATCH 2/2] config kNumLevels for TEST LastLevelCompaction --- test/ttl_test.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/ttl_test.cc b/test/ttl_test.cc index b20194d..ea71c06 100644 --- a/test/ttl_test.cc +++ b/test/ttl_test.cc @@ -104,9 +104,7 @@ TEST(TestTTL, CompactionTTL) { delete db; } -// Time-consuming when kNumLevels is 7, so run this test when kNumLevels is set to 3, -// the codes on branch light_ver -// In this case level 2 is the last level with files +// Test handling last level with kNumLevels = 3 TEST(TestTTL, LastLevelCompaction) { DB *db;