|
|
@ -604,34 +604,6 @@ void DBImpl::TEST_CompactRange(int level, const Slice* begin, |
|
|
|
assert(level >= 0); |
|
|
|
assert(level < config::kNumLevels); |
|
|
|
|
|
|
|
// if (level == config::kNumLevels - 1) {
|
|
|
|
// // TTL: TODO: update files in the last level
|
|
|
|
// mutex_.AssertHeld();
|
|
|
|
|
|
|
|
// Compaction* c;
|
|
|
|
// c = versions_->CompactRange(level, begin, end);
|
|
|
|
|
|
|
|
// Iterator* files = versions_->MakeInputIterator(c);
|
|
|
|
|
|
|
|
// while (files->Valid() && !shutting_down_.load(std::memory_order_acquire)) {
|
|
|
|
// std::string value = files->value().ToString();
|
|
|
|
// uint64_t ddl;
|
|
|
|
// DecodeDeadLineValue(&value, ddl);
|
|
|
|
|
|
|
|
// if (ddl != 0) {
|
|
|
|
// if (ddl <= std::time(nullptr)) {
|
|
|
|
// c->edit()->RemoveFile(c->level(), number);
|
|
|
|
// versions_->LogAndApply(c->edit(), &mutex_);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// files->Next();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
InternalKey begin_storage, end_storage; |
|
|
|
|
|
|
|
ManualCompaction manual; |
|
|
@ -947,8 +919,14 @@ Status DBImpl::InstallCompactionResults(CompactionState* compact) { |
|
|
|
const int level = compact->compaction->level(); |
|
|
|
for (size_t i = 0; i < compact->outputs.size(); i++) { |
|
|
|
const CompactionState::Output& out = compact->outputs[i]; |
|
|
|
compact->compaction->edit()->AddFile(level + 1, out.number, out.file_size, |
|
|
|
out.smallest, out.largest); |
|
|
|
if (level < config::kNumLevels - 1) { |
|
|
|
compact->compaction->edit()->AddFile(level + 1, out.number, out.file_size, |
|
|
|
out.smallest, out.largest); |
|
|
|
} else { |
|
|
|
// TTL: outputs of last level compaction should be writen to last level itself
|
|
|
|
compact->compaction->edit()->AddFile(level, out.number, out.file_size, |
|
|
|
out.smallest, out.largest); |
|
|
|
} |
|
|
|
} |
|
|
|
return versions_->LogAndApply(compact->compaction->edit(), &mutex_); |
|
|
|
} |
|
|
@ -1109,7 +1087,12 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) { |
|
|
|
} |
|
|
|
|
|
|
|
mutex_.Lock(); |
|
|
|
stats_[compact->compaction->level() + 1].Add(stats); |
|
|
|
if (compact->compaction->level() + 1 < config::kNumLevels) { |
|
|
|
stats_[compact->compaction->level() + 1].Add(stats); |
|
|
|
} else { |
|
|
|
// TTL: compaction for last level
|
|
|
|
stats_[compact->compaction->level()].Add(stats); |
|
|
|
} |
|
|
|
|
|
|
|
if (status.ok()) { |
|
|
|
status = InstallCompactionResults(compact); |
|
|
|