Fix bloom filters

Summary: https://reviews.facebook.net/D13167 broke bloom filters. If filter is not in cache, we want to return true (safe thing). Am I right?

Test Plan: when benchmarking https://reviews.facebook.net/D14031 I got different results when using bloom filters vs. when not using them. This fixed the issue. I will also be putting this change to the other diff, but that one will probably be in review for longer time.

Reviewers: kailiu, dhruba, haobo

Reviewed By: kailiu

CC: leveldb

Differential Revision: https://reviews.facebook.net/D14085
This commit is contained in:
Igor Canadi 2013-11-14 14:05:15 -08:00
parent fda8142f29
commit e0ad0f26b8

View File

@ -904,7 +904,10 @@ bool BlockBasedTable::PrefixMayMatch(const Slice& internal_prefix) {
if (!iiter->Valid()) {
// we're past end of file
may_match = false;
// if it's incomplete, it means that we avoided I/O
// and we're not really sure that we're past the end
// of the file
may_match = iiter->status().IsIncomplete();
} else if (ExtractUserKey(iiter->key()).starts_with(
ExtractUserKey(internal_prefix))) {
// we need to check for this subtle case because our only
@ -930,7 +933,7 @@ bool BlockBasedTable::PrefixMayMatch(const Slice& internal_prefix) {
assert(s.ok());
auto filter_entry = GetFilter(true /* no io */);
may_match =
filter_entry.value != nullptr &&
filter_entry.value == nullptr ||
filter_entry.value->PrefixMayMatch(handle.offset(), internal_prefix);
filter_entry.Release(rep_->options.block_cache.get());
}