]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
BlockBasedTable::Get() not to use prefix bloom if read_options.total_order_seek ...
authorsdong <siying.d@fb.com>
Fri, 6 May 2016 00:20:22 +0000 (17:20 -0700)
committersdong <siying.d@fb.com>
Fri, 6 May 2016 17:18:03 +0000 (10:18 -0700)
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

db/db_bloom_filter_test.cc
include/rocksdb/options.h
table/block_based_table_reader.cc
table/block_based_table_reader.h

index b9a86c31fceb936ce1d0dbe7bcee950f36e4b501..4bc9453ad8cc30f5799cc5785f0e6808027bd8c8 100644 (file)
@@ -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) {
index d93af2314bae08388b56b7cef106e3df098f8cc2..80104c7fd025fbc4025b62a4c1c1ca8eaa23e0de 100644 (file)
@@ -1448,6 +1448,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.
index 849813c41e4039f161476081f5d00f3fe9d6dc9c..82c9903fa7dbad7922b40bcd40663bbf6d0b225a 100644 (file)
@@ -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;
index 8f55f119b9e3347dfbeea7fd2d83e4b655940834..45b303e0ea7ee24fab8dda016943d7f0cebdd946 100644 (file)
@@ -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.