Skip to content

Commit

Permalink
skip files before lookup key in internal key ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkr committed Jan 3, 2019
1 parent 4b031b7 commit 61b8571
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions db/version_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,6 @@ class FilePicker {
break;
}
}
if (cmp_largest == 0 &&
GetInternalKeySeqno(f->largest_key) == kMaxSequenceNumber) {
assert(ExtractValueType(f->largest_key) == kTypeRangeDeletion);
// Key falls at the range tombstone sentinel endpoint. Proceed to
// next level.
break;
}
}
#ifndef NDEBUG
// Sanity check to make sure that the files are correctly sorted
Expand Down Expand Up @@ -315,10 +308,23 @@ class FilePicker {
search_right_bound_ =
static_cast<int32_t>(curr_file_level_->num_files) - 1;
}
// `search_right_bound_` is an inclusive upper-bound, but since it was
// determined based on user key, it is still possible the lookup key
// falls to the right of `search_right_bound_`'s corresponding file.
// So, pass a limit one higher, which allows us to detect this case.
start_index =
FindFileInRange(*internal_comparator_, *curr_file_level_, ikey_,
static_cast<uint32_t>(search_left_bound_),
static_cast<uint32_t>(search_right_bound_));
static_cast<uint32_t>(search_right_bound_) + 1);
if (start_index == search_right_bound_ + 1) {
// `ikey_` comes after `search_right_bound_`. The lookup key does
// not exist on this level, so let's skip this level and do a full
// binary search on the next level.
search_left_bound_ = 0;
search_right_bound_ = FileIndexer::kLevelMaxIndex;
curr_level_++;
continue;
}
} else {
// search_left_bound > search_right_bound, key does not exist in
// this level. Since no comparison is done in this level, it will
Expand Down

0 comments on commit 61b8571

Please sign in to comment.