소스 검색

a naive version to pass ttl_test

naive_version
ArcueidType 3 주 전
부모
커밋
57cd670dcc
2개의 변경된 파일23개의 추가작업 그리고 4개의 파일을 삭제
  1. +9
    -2
      db/builder.cc
  2. +14
    -2
      db/db_impl.cc

+ 9
- 2
db/builder.cc 파일 보기

@ -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 파일 보기

@ -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;

불러오는 중...
취소
저장