|
@ -604,10 +604,33 @@ void DBImpl::TEST_CompactRange(int level, const Slice* begin, |
|
|
assert(level >= 0); |
|
|
assert(level >= 0); |
|
|
assert(level < config::kNumLevels); |
|
|
assert(level < config::kNumLevels); |
|
|
|
|
|
|
|
|
if (level + 1 == config::kNumLevels) { |
|
|
|
|
|
// TTL: TODO: update files in the last level
|
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 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; |
|
|
InternalKey begin_storage, end_storage; |
|
|
|
|
|
|
|
@ -627,6 +650,34 @@ void DBImpl::TEST_CompactRange(int level, const Slice* begin, |
|
|
manual.end = &end_storage; |
|
|
manual.end = &end_storage; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (level == config::kNumLevels - 1) { |
|
|
|
|
|
// TTL: TODO: update files in the last level
|
|
|
|
|
|
mutex_.AssertHeld(); |
|
|
|
|
|
|
|
|
|
|
|
Compaction* c; |
|
|
|
|
|
c = versions_->CompactRange(level, nullptr, nullptr); |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
} // ttl end
|
|
|
|
|
|
|
|
|
MutexLock l(&mutex_); |
|
|
MutexLock l(&mutex_); |
|
|
while (!manual.done && !shutting_down_.load(std::memory_order_acquire) && |
|
|
while (!manual.done && !shutting_down_.load(std::memory_order_acquire) && |
|
|
bg_error_.ok()) { |
|
|
bg_error_.ok()) { |
|
|