Newbie code question

Summary:
This diff is more about my question when reading compaction codes,
instead of a normal diff. I don't quite understand the logic here.

Test Plan: I didn't do any test. If this is a bug, I will continue doing some test.

Reviewers: haobo, dhruba, emayanke

Reviewed By: dhruba

CC: leveldb

Differential Revision: https://reviews.facebook.net/D11661
This commit is contained in:
Xing Jin 2013-07-11 09:03:40 -07:00
parent 821889e207
commit 8a5341ec7d

View File

@ -1974,7 +1974,7 @@ Compaction* VersionSet::PickCompactionBySize(int level, double score) {
assert(level >= 0); assert(level >= 0);
assert(level+1 < NumberLevels()); assert(level+1 < NumberLevels());
c = new Compaction(level, MaxFileSizeForLevel(level), c = new Compaction(level, MaxFileSizeForLevel(level+1),
MaxGrandParentOverlapBytes(level), NumberLevels()); MaxGrandParentOverlapBytes(level), NumberLevels());
c->score_ = score; c->score_ = score;
@ -2072,7 +2072,7 @@ Compaction* VersionSet::PickCompaction() {
if (level != 0 || compactions_in_progress_[0].empty()) { if (level != 0 || compactions_in_progress_[0].empty()) {
if(!ParentRangeInCompaction(&f->smallest, &f->largest, level, if(!ParentRangeInCompaction(&f->smallest, &f->largest, level,
&parent_index)) { &parent_index)) {
c = new Compaction(level, MaxFileSizeForLevel(level), c = new Compaction(level, MaxFileSizeForLevel(level+1),
MaxGrandParentOverlapBytes(level), NumberLevels(), true); MaxGrandParentOverlapBytes(level), NumberLevels(), true);
c->inputs_[0].push_back(f); c->inputs_[0].push_back(f);
c->parent_index_ = parent_index; c->parent_index_ = parent_index;
@ -2247,7 +2247,7 @@ Compaction* VersionSet::CompactRange(
} }
} }
Compaction* c = new Compaction(level, MaxFileSizeForLevel(level), Compaction* c = new Compaction(level, MaxFileSizeForLevel(level+1),
MaxGrandParentOverlapBytes(level), NumberLevels()); MaxGrandParentOverlapBytes(level), NumberLevels());
c->input_version_ = current_; c->input_version_ = current_;
c->input_version_->Ref(); c->input_version_->Ref();