瀏覽代碼

fix bug

main
neal-zhu 5 年之前
父節點
當前提交
8fa7a937ee
共有 1 個檔案被更改,包括 14 行新增8 行删除
  1. +14
    -8
      db/version_set.cc

+ 14
- 8
db/version_set.cc 查看文件

@ -328,7 +328,9 @@ Status Version::Get(const ReadOptions& options, const LookupKey& k,
Slice ikey = k.internal_key(); Slice ikey = k.internal_key();
Slice user_key = k.user_key(); Slice user_key = k.user_key();
const Comparator* ucmp = vset_->icmp_.user_comparator(); const Comparator* ucmp = vset_->icmp_.user_comparator();
Status s;
stats->seek_file = nullptr;
stats->seek_file_level = -1;
struct State { struct State {
GetStats* stats; GetStats* stats;
@ -337,6 +339,8 @@ Status Version::Get(const ReadOptions& options, const LookupKey& k,
Slice user_key; Slice user_key;
const Comparator* ucmp; const Comparator* ucmp;
std::string* value; std::string* value;
FileMetaData *last_file_read;
int last_file_level;
VersionSet *vset; VersionSet *vset;
Status s; Status s;
@ -344,11 +348,13 @@ Status Version::Get(const ReadOptions& options, const LookupKey& k,
static bool Match(void* arg, int level, FileMetaData* f) { static bool Match(void* arg, int level, FileMetaData* f) {
State* state = reinterpret_cast<State*>(arg); 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. // 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 saver;
saver.state = kNotFound; 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 state;
state.s = Status::NotFound(Slice()); state.s = Status::NotFound(Slice());
state.stats = stats; state.stats = stats;
state.last_file_read = nullptr;
state.last_file_level = -1;
state.ikey = ikey; state.ikey = ikey;
state.user_key = user_key; state.user_key = user_key;
state.ucmp = ucmp; state.ucmp = ucmp;
state.value = value; state.value = value;
state.vset = vset_; state.vset = vset_;
ForEachOverlapping(user_key, ikey, &state, &State::Match); ForEachOverlapping(user_key, ikey, &state, &State::Match);
return state.s; return state.s;

Loading…
取消
儲存