forked from facebook/rocksdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid per-key upper bound check in BlockBasedTableIterator (facebook#…
…5142) Summary: This is second attempt for facebook#5101. Original commit message: `BlockBasedTableIterator` avoid reading next block on `Next()` if it detects the iterator will be out of bound, by checking against index key. The optimization was added in facebook#2239, and by the time it only check the bound per block. It seems later change make it a per-key check, which introduce unnecessary key comparisons. This patch come with two fixes: Fix 1: To optimize checking for bounds, we need comparing the bounds with index key as well. However BlockBasedTableIterator doesn't know whether its index iterator is internally using user keys or internal keys. The patch fixes that by extending InternalIterator with a user_key() function that is overridden by In IndexBlockIter. Fix 2: In facebook#5101 we return `IsOutOfBound()=true` when block index key is out of bound. But the index key can be larger than smallest key of the next file on the level. That file can be within upper bound and should not be filtered out. Pull Request resolved: facebook#5142 Differential Revision: D14907113 Pulled By: siying fbshipit-source-id: ac95775c5b4e7b700f76ab43e39f45402c98fbfb
- Loading branch information
1 parent
71a82a0
commit f1239d5
Showing
11 changed files
with
220 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved. | ||
// This source code is licensed under both the GPLv2 (found in the | ||
// COPYING file in the root directory) and Apache 2.0 License | ||
// (found in the LICENSE.Apache file in the root directory). | ||
|
||
#include "rocksdb/flush_block_policy.h" | ||
|
||
namespace rocksdb { | ||
|
||
// FlushBlockEveryKeyPolicy currently used only in tests. | ||
|
||
class FlushBlockEveryKeyPolicy : public FlushBlockPolicy { | ||
public: | ||
bool Update(const Slice& /*key*/, const Slice& /*value*/) override { | ||
if (!start_) { | ||
start_ = true; | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
private: | ||
bool start_ = false; | ||
}; | ||
|
||
class FlushBlockEveryKeyPolicyFactory : public FlushBlockPolicyFactory { | ||
public: | ||
explicit FlushBlockEveryKeyPolicyFactory() {} | ||
|
||
const char* Name() const override { | ||
return "FlushBlockEveryKeyPolicyFactory"; | ||
} | ||
|
||
FlushBlockPolicy* NewFlushBlockPolicy( | ||
const BlockBasedTableOptions& /*table_options*/, | ||
const BlockBuilder& /*data_block_builder*/) const override { | ||
return new FlushBlockEveryKeyPolicy; | ||
} | ||
}; | ||
|
||
} // namespace rocksdb |
Oops, something went wrong.