neal-zhu 5 yıl önce
ebeveyn
işleme
8fa7a937ee
1 değiştirilmiş dosya ile 14 ekleme ve 8 silme
  1. +14
    -8
      db/version_set.cc

+ 14
- 8
db/version_set.cc Dosyayı Görüntüle

@ -328,7 +328,9 @@ Status Version::Get(const ReadOptions& options, const LookupKey& k,
Slice ikey = k.internal_key();
Slice user_key = k.user_key();
const Comparator* ucmp = vset_->icmp_.user_comparator();
Status s;
stats->seek_file = nullptr;
stats->seek_file_level = -1;
struct State {
GetStats* stats;
@ -337,6 +339,8 @@ Status Version::Get(const ReadOptions& options, const LookupKey& k,
Slice user_key;
const Comparator* ucmp;
std::string* value;
FileMetaData *last_file_read;
int last_file_level;
VersionSet *vset;
Status s;
@ -344,11 +348,13 @@ Status Version::Get(const ReadOptions& options, const LookupKey& k,
static bool Match(void* arg, int level, FileMetaData* f) {
State* state = reinterpret_cast<State*>(arg);
if (state->stats->seek_file == nullptr) {
if (state->last_file_read != nullptr && state->stats->seek_file == nullptr) {
// We have had more than one seek for this read. Charge the 1st file.
state->stats->seek_file = f;
state->stats->seek_file_level = level;
state->stats->seek_file = state->last_file_read;
state->stats->seek_file_level = state->last_file_level;
}
state->last_file_read = f;
state->last_file_level = level;
Saver saver;
saver.state = kNotFound;
@ -378,18 +384,18 @@ Status Version::Get(const ReadOptions& options, const LookupKey& k,
}
};
stats->seek_file = nullptr;
stats->seek_file_level = -1;
State state;
state.s = Status::NotFound(Slice());
state.stats = stats;
state.last_file_read = nullptr;
state.last_file_level = -1;
state.ikey = ikey;
state.user_key = user_key;
state.ucmp = ucmp;
state.value = value;
state.vset = vset_;
ForEachOverlapping(user_key, ikey, &state, &State::Match);
return state.s;

Yükleniyor…
İptal
Kaydet