BlockBasedTable::Get() not to use prefix bloom if read_options.total_order_seek = true

Summary: This is to provide a way for users to skip prefix bloom in point look-up.

Test Plan: Add a new unit test scenario.

Reviewers: IslamAbdelRahman

Subscribers: leveldb, andrewkr, dhruba

Differential Revision: https://reviews.facebook.net/D57747
main
sdong 9 years ago
parent e3c6ba37dd
commit 7ccb8d6ef3
  1. 4
      db/db_bloom_filter_test.cc
  2. 3
      include/rocksdb/options.h
  3. 7
      table/block_based_table_reader.cc
  4. 3
      table/block_based_table_reader.h

@ -160,6 +160,10 @@ TEST_F(DBBloomFilterTest, GetFilterByPrefixBloom) {
ASSERT_EQ("NOT_FOUND", Get("foobarbar"));
ASSERT_EQ(TestGetTickerCount(options, BLOOM_FILTER_USEFUL), 2);
ro.total_order_seek = true;
ASSERT_TRUE(db_->Get(ro, "foobarbar", &value).IsNotFound());
ASSERT_EQ(TestGetTickerCount(options, BLOOM_FILTER_USEFUL), 2);
}
TEST_F(DBBloomFilterTest, WholeKeyFilterProp) {

@ -1458,6 +1458,9 @@ struct ReadOptions {
// Enable a total order seek regardless of index format (e.g. hash index)
// used in the table. Some table format (e.g. plain table) may not support
// this option.
// If true when calling Get(), we also skip prefix bloom when reading from
// block based table. It provides a way to read exisiting data after
// changing implementation of prefix extractor.
bool total_order_seek;
// Enforce that the iterator only iterates over the same prefix as the seek.

@ -1332,7 +1332,8 @@ InternalIterator* BlockBasedTable::NewIterator(const ReadOptions& read_options,
NewIndexIterator(read_options), arena);
}
bool BlockBasedTable::FullFilterKeyMayMatch(FilterBlockReader* filter,
bool BlockBasedTable::FullFilterKeyMayMatch(const ReadOptions& read_options,
FilterBlockReader* filter,
const Slice& internal_key) const {
if (filter == nullptr || filter->IsBlockBased()) {
return true;
@ -1341,7 +1342,7 @@ bool BlockBasedTable::FullFilterKeyMayMatch(FilterBlockReader* filter,
if (!filter->KeyMayMatch(user_key)) {
return false;
}
if (rep_->ioptions.prefix_extractor &&
if (!read_options.total_order_seek && rep_->ioptions.prefix_extractor &&
rep_->ioptions.prefix_extractor->InDomain(user_key) &&
!filter->PrefixMayMatch(
rep_->ioptions.prefix_extractor->Transform(user_key))) {
@ -1361,7 +1362,7 @@ Status BlockBasedTable::Get(const ReadOptions& read_options, const Slice& key,
// First check the full filter
// If full filter not useful, Then go into each block
if (!FullFilterKeyMayMatch(filter, key)) {
if (!FullFilterKeyMayMatch(read_options, filter, key)) {
RecordTick(rep_->ioptions.statistics, BLOOM_FILTER_USEFUL);
} else {
BlockIter iiter;

@ -207,7 +207,8 @@ class BlockBasedTable : public TableReader {
IndexReader** index_reader,
InternalIterator* preloaded_meta_index_iter = nullptr);
bool FullFilterKeyMayMatch(FilterBlockReader* filter,
bool FullFilterKeyMayMatch(const ReadOptions& read_options,
FilterBlockReader* filter,
const Slice& user_key) const;
// Read the meta block from sst.

Loading…
Cancel
Save