xxy преди 3 седмици
родител
ревизия
c8e0d2b2c6
променени са 5 файла, в които са добавени 38 реда и са изтрити 3 реда
  1. +4
    -0
      db/db_impl.cc
  2. +6
    -1
      db/version_set.cc
  3. +26
    -0
      test/db_test1.cc
  4. +1
    -1
      third_party/benchmark
  5. +1
    -1
      third_party/googletest

+ 4
- 0
db/db_impl.cc Целия файл

@ -924,6 +924,10 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) {
bool has_current_user_key = false;
SequenceNumber last_sequence_for_key = kMaxSequenceNumber;
while (input->Valid() && !shutting_down_.load(std::memory_order_acquire)) {
auto x=input->value();
uint64_t ttl=*(uint64_t*)(x.data()+x.size()-sizeof(uint64_t));
time_t now = time(nullptr);
if(ttl < static_cast<uint64_t>(now))return;
// Prioritize immutable compaction work
if (has_imm_.load(std::memory_order_relaxed)) {
const uint64_t imm_start = env_->NowMicros();

+ 6
- 1
db/version_set.cc Целия файл

@ -266,9 +266,14 @@ static void SaveValue(void* arg, const Slice& ikey, const Slice& v) {
s->state = kCorrupt;
} else {
if (s->ucmp->Compare(parsed_key.user_key, s->user_key) == 0) {
if(parsed_key.type == kTypeValue){
time_t now = time(nullptr);
uint64_t ttl=*(uint64_t*)(v.data()+v.size()-sizeof(uint64_t));
if(ttl < static_cast<uint64_t>(now))return;
}
s->state = (parsed_key.type == kTypeValue) ? kFound : kDeleted;
if (s->state == kFound) {
s->value->assign(v.data(), v.size());
s->value->assign(v.data(), v.size()-sizeof(uint64_t));
}
}
}

+ 26
- 0
test/db_test1.cc Целия файл

@ -0,0 +1,26 @@
#include "leveldb/db.h"
#include <iostream>
using namespace std;
using namespace leveldb;
int main() {
DB* db = nullptr;
Options op;
op.create_if_missing = true;
Status status = DB::Open(op, "testdb", &db);
assert(status.ok());
db->Put(WriteOptions(), "001", "leveldb");
string s;
db->Get(ReadOptions(), "001", &s);
cout<<s<<endl;
db->Put(WriteOptions(), "002", "world");
string s1;
db->Delete(WriteOptions(), "002");
db->Get(ReadOptions(), "002", &s1);
cout<<s1<<endl;
delete db;
return 0;
}

+ 1
- 1
third_party/benchmark

@ -1 +1 @@
Subproject commit f7547e29ccaed7b64ef4f7495ecfff1c9f6f3d03
Subproject commit d99cdd7356de97b3056684d6b511189778d8a247

+ 1
- 1
third_party/googletest

@ -1 +1 @@
Subproject commit 662fe38e44900c007eccb65a5d2ea19df7bd520e
Subproject commit 5ed21863955149a5a877a53d7d5045b6919090ed

Зареждане…
Отказ
Запис