|
|
@ -591,6 +591,7 @@ void DBImpl::CompactRange(const Slice* begin, const Slice* end) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
max_level_with_files = config::kNumLevels - 1; //TODO:强制合并所有level中的sst,但是这么做不是很优雅
|
|
|
|
TEST_CompactMemTable(); // TODO(sanjay): Skip if memtable does not overlap
|
|
|
|
for (int level = 0; level < max_level_with_files; level++) { |
|
|
|
TEST_CompactRange(level, begin, end); |
|
|
@ -951,11 +952,20 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) { |
|
|
|
|
|
|
|
// Handle key/value, add to state, etc.
|
|
|
|
bool drop = false; |
|
|
|
time_t nowTime; |
|
|
|
time(&nowTime); |
|
|
|
if (!ParseInternalKey(key, &ikey)) { |
|
|
|
// Do not hide error keys
|
|
|
|
current_user_key.clear(); |
|
|
|
has_current_user_key = false; |
|
|
|
last_sequence_for_key = kMaxSequenceNumber; |
|
|
|
} else if(ikey.deadTime != 0 && ikey.deadTime < nowTime){ |
|
|
|
static int count = 0; |
|
|
|
if(count % 1000 == 0) { |
|
|
|
std::cout<<"count "<<count<<" drop dead in Compaction: "<<ikey.user_key.ToString()<<" "<<ikey.deadTime<<std::endl; |
|
|
|
count ++; |
|
|
|
} |
|
|
|
drop = true; |
|
|
|
} else { |
|
|
|
if (!has_current_user_key || |
|
|
|
user_comparator()->Compare(ikey.user_key, Slice(current_user_key)) != |
|
|
@ -981,7 +991,6 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) { |
|
|
|
// Therefore this deletion marker is obsolete and can be dropped.
|
|
|
|
drop = true; |
|
|
|
} |
|
|
|
|
|
|
|
last_sequence_for_key = ikey.sequence; |
|
|
|
} |
|
|
|
#if 0
|
|
|
@ -993,7 +1002,6 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) { |
|
|
|
compact->compaction->IsBaseLevelForKey(ikey.user_key), |
|
|
|
(int)last_sequence_for_key, (int)compact->smallest_snapshot); |
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!drop) { |
|
|
|
// Open output file if necessary
|
|
|
|
if (compact->builder == nullptr) { |
|
|
|