You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original issue 199 created by zju.zhengmh on 2013-08-21T06:39:43.000Z:
In Leveldb 1.11, it fixed isssue 178 by not pick level-0 files when do CompactRange.
But we can pick level-0 oldest files for CompactRange, which we ca sort files if it is level0. It will be more reasonable, since it can avoid too much level-0 files.
diff --git a/db/version_set.cc b/db/version_set.cc
index 4fd1dde..21b76ee 100644
--- a/db/version_set.cc+++ b/db/version_set.cc@@ -289,6 +289,11 @@ static bool NewestFirst(FileMetaData* a, FileMetaData* b) {
return a->number > b->number;
}
+static bool OldestFirst(FileMetaData* a, FileMetaData* b) {+ return a->number < b->number;+}++
Status Version::Get(const ReadOptions& options,
const LookupKey& k,
std::string* value,
@@ -1333,17 +1338,19 @@ Compaction* VersionSet::CompactRange(
// Avoid compacting too much in one shot in case the range is large.
// But we cannot do this for level-0 since level-0 files can overlap
// and we must not pick one file and drop another older file if the
- // two files overlap.- if (level > 0) {- const uint64_t limit = MaxFileSizeForLevel(level);- uint64_t total = 0;- for (size_t i = 0; i < inputs.size(); i++) {- uint64_t s = inputs[i]->file_size;- total += s;- if (total >= limit) {- inputs.resize(i + 1);- break;- }+ // two files overlap. For level-0, we can pick oldest files.+ if (level == 0) {+ std::sort(inputs.begin(), inputs.end(), OldestFirst);+ }++ const uint64_t limit = MaxFileSizeForLevel(level);+ uint64_t total = 0;+ for (size_t i = 0; i < inputs.size(); i++) {+ uint64_t s = inputs[i]->file_size;+ total += s;+ if (total >= limit) {+ inputs.resize(i + 1);+ break;
}
}
The text was updated successfully, but these errors were encountered:
Original issue 199 created by zju.zhengmh on 2013-08-21T06:39:43.000Z:
In Leveldb 1.11, it fixed isssue 178 by not pick level-0 files when do CompactRange.
But we can pick level-0 oldest files for CompactRange, which we ca sort files if it is level0. It will be more reasonable, since it can avoid too much level-0 files.
The text was updated successfully, but these errors were encountered: