Procházet zdrojové kódy

a naive version to pass ttl_test

naive_version
ArcueidType před 3 týdny
rodič
revize
57cd670dcc
2 změnil soubory, kde provedl 23 přidání a 4 odebrání
  1. +9
    -2
      db/builder.cc
  2. +14
    -2
      db/db_impl.cc

+ 9
- 2
db/builder.cc Zobrazit soubor

@ -32,8 +32,15 @@ Status BuildTable(const std::string& dbname, Env* env, const Options& options,
meta->smallest.DecodeFrom(iter->key());
Slice key;
for (; iter->Valid(); iter->Next()) {
key = iter->key();
builder->Add(key, iter->value());
// std::string value;
// uint64_t ddl;
// value = iter->value().ToString();
// DecodeDeadLineValue(&value, ddl);
// if (ddl > std::time(nullptr)) {
// TTL: only liver remains
key = iter->key();
builder->Add(key, iter->value());
// }
}
if (!key.empty()) {
meta->largest.DecodeFrom(key);

+ 14
- 2
db/db_impl.cc Zobrazit soubor

@ -594,7 +594,7 @@ void DBImpl::CompactRange(const Slice* begin, const Slice* end) {
}
}
TEST_CompactMemTable(); // TODO(sanjay): Skip if memtable does not overlap
for (int level = 0; level < max_level_with_files; level++) {
for (int level = 0; level < max_level_with_files + 1; level++) {
TEST_CompactRange(level, begin, end);
}
}
@ -602,7 +602,11 @@ void DBImpl::CompactRange(const Slice* begin, const Slice* end) {
void DBImpl::TEST_CompactRange(int level, const Slice* begin,
const Slice* end) {
assert(level >= 0);
assert(level + 1 < config::kNumLevels);
assert(level <= config::kNumLevels);
if (level == config::kNumLevels) {
return;
}
InternalKey begin_storage, end_storage;
@ -966,6 +970,11 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) {
last_sequence_for_key = kMaxSequenceNumber;
}
std::string value = input->value().ToString();
uint64_t ddl;
DecodeDeadLineValue(&value, ddl);
if (last_sequence_for_key <= compact->smallest_snapshot) {
// Hidden by an newer entry for same user key
drop = true; // (A)
@ -980,6 +989,9 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) {
// few iterations of this loop (by rule (A) above).
// Therefore this deletion marker is obsolete and can be dropped.
drop = true;
} else if (ddl <= std::time(nullptr)) {
// TTL: data expired
drop = true;
}
last_sequence_for_key = ikey.sequence;

Načítá se…
Zrušit
Uložit