|
@ -598,6 +598,7 @@ void DBImpl::CompactRange(const Slice* begin, const Slice* end) { |
|
|
for (int level = 0; level < max_level_with_files; level++) { |
|
|
for (int level = 0; level < max_level_with_files; level++) { |
|
|
TEST_CompactRange(level, begin, end); |
|
|
TEST_CompactRange(level, begin, end); |
|
|
} |
|
|
} |
|
|
|
|
|
TEST_CompactRange(max_level_with_files, begin, end); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void DBImpl::TEST_CompactRange(int level, const Slice* begin, |
|
|
void DBImpl::TEST_CompactRange(int level, const Slice* begin, |
|
@ -756,7 +757,7 @@ void DBImpl::BackgroundCompaction() { |
|
|
status.ToString().c_str(), versions_->LevelSummary(&tmp)); |
|
|
status.ToString().c_str(), versions_->LevelSummary(&tmp)); |
|
|
} else { |
|
|
} else { |
|
|
CompactionState* compact = new CompactionState(c); |
|
|
CompactionState* compact = new CompactionState(c); |
|
|
status = DoCompactionWork(compact); |
|
|
|
|
|
|
|
|
status = DoCompactionWork(compact);//
|
|
|
if (!status.ok()) { |
|
|
if (!status.ok()) { |
|
|
RecordBackgroundError(status); |
|
|
RecordBackgroundError(status); |
|
|
} |
|
|
} |
|
@ -917,7 +918,6 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Iterator* input = versions_->MakeInputIterator(compact->compaction); |
|
|
Iterator* input = versions_->MakeInputIterator(compact->compaction); |
|
|
|
|
|
|
|
|
// Release mutex while we're actually doing the compaction work
|
|
|
// Release mutex while we're actually doing the compaction work
|
|
|
mutex_.Unlock(); |
|
|
mutex_.Unlock(); |
|
|
|
|
|
|
|
@ -949,7 +949,7 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
auto a = DecodeFixed64(input->value().data() + input->value().size() - kTSLength); |
|
|
// Handle key/value, add to state, etc.
|
|
|
// Handle key/value, add to state, etc.
|
|
|
bool drop = false; |
|
|
bool drop = false; |
|
|
if (!ParseInternalKey(key, &ikey)) { |
|
|
if (!ParseInternalKey(key, &ikey)) { |
|
@ -981,6 +981,9 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) { |
|
|
// few iterations of this loop (by rule (A) above).
|
|
|
// few iterations of this loop (by rule (A) above).
|
|
|
// Therefore this deletion marker is obsolete and can be dropped.
|
|
|
// Therefore this deletion marker is obsolete and can be dropped.
|
|
|
drop = true; |
|
|
drop = true; |
|
|
|
|
|
}else if(DecodeFixed64(input->value().data() + input->value().size() - kTSLength) < env_->NowMicros()){ |
|
|
|
|
|
|
|
|
|
|
|
drop = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
last_sequence_for_key = ikey.sequence; |
|
|
last_sequence_for_key = ikey.sequence; |
|
@ -1228,7 +1231,7 @@ Status DBImpl::Put(const WriteOptions& options, const Slice& key, |
|
|
std::string val_with_ts; |
|
|
std::string val_with_ts; |
|
|
val_with_ts.reserve(value.size() + kTSLength); |
|
|
val_with_ts.reserve(value.size() + kTSLength); |
|
|
char ts_string[kTSLength]; |
|
|
char ts_string[kTSLength]; |
|
|
TIMESTAMP expiration_time = this->env_->GetCurrentTime() + ttl * 1000; |
|
|
|
|
|
|
|
|
TIMESTAMP expiration_time = this->env_->NowMicros() + ttl * 1000000; |
|
|
EncodeFixed64(ts_string,expiration_time); |
|
|
EncodeFixed64(ts_string,expiration_time); |
|
|
//assert(sizeof(expiration_time) == sizeof(TIMESTAMP ));
|
|
|
//assert(sizeof(expiration_time) == sizeof(TIMESTAMP ));
|
|
|
// 追加原始 value 到 val_with_ts
|
|
|
// 追加原始 value 到 val_with_ts
|
|
@ -1577,7 +1580,7 @@ uint64_t DBImpl::GetTS(std::string* val) { |
|
|
} |
|
|
} |
|
|
Status DBImpl::CheckIsExpire(std::string* value) { |
|
|
Status DBImpl::CheckIsExpire(std::string* value) { |
|
|
//debug 用
|
|
|
//debug 用
|
|
|
auto a = env_->GetCurrentTime(); |
|
|
|
|
|
|
|
|
auto a = env_->NowMicros(); |
|
|
auto b = GetTS(value); |
|
|
auto b = GetTS(value); |
|
|
// std::cout<<"get current time"<<a<<std::endl;
|
|
|
// std::cout<<"get current time"<<a<<std::endl;
|
|
|
// std::cout << "get ts from val"<<b<<std::endl;
|
|
|
// std::cout << "get ts from val"<<b<<std::endl;
|
|
|