Add TableOptions for BlockBasedTableFactory
We are having more and more options to specify for this table so it makes sense to have a TableOptions for future extension.
This commit is contained in:
parent
db2e2615f8
commit
56589ab81f
@ -29,7 +29,8 @@ Status BlockBasedTableFactory::GetTableReader(
|
||||
TableBuilder* BlockBasedTableFactory::GetTableBuilder(
|
||||
const Options& options, WritableFile* file,
|
||||
CompressionType compression_type) const {
|
||||
auto flush_block_policy_factory = flush_block_policy_factory_.get();
|
||||
auto flush_block_policy_factory =
|
||||
table_options_.flush_block_policy_factory.get();
|
||||
|
||||
// if flush block policy factory is not set, we'll create the default one
|
||||
// from the options.
|
||||
@ -54,7 +55,8 @@ TableBuilder* BlockBasedTableFactory::GetTableBuilder(
|
||||
// options.
|
||||
// We can safely delete flush_block_policy_factory since it will only be used
|
||||
// during the construction of `BlockBasedTableBuilder`.
|
||||
if (flush_block_policy_factory != flush_block_policy_factory_.get()) {
|
||||
if (flush_block_policy_factory !=
|
||||
table_options_.flush_block_policy_factory.get()) {
|
||||
delete flush_block_policy_factory;
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,18 @@ class BlockBasedTableBuilder;
|
||||
|
||||
class BlockBasedTableFactory: public TableFactory {
|
||||
public:
|
||||
// @flush_block_policy_factory creates the instances of flush block policy.
|
||||
// which provides a configurable way to determine when to flush a block in
|
||||
// the block based tables. If not set, table builder will use the default
|
||||
// block flush policy, which cut blocks by block size (please refer to
|
||||
// `FlushBlockBySizePolicy`).
|
||||
BlockBasedTableFactory(
|
||||
FlushBlockPolicyFactory* flush_block_policy_factory = nullptr) :
|
||||
flush_block_policy_factory_(flush_block_policy_factory) {
|
||||
struct TableOptions {
|
||||
// @flush_block_policy_factory creates the instances of flush block policy.
|
||||
// which provides a configurable way to determine when to flush a block in
|
||||
// the block based tables. If not set, table builder will use the default
|
||||
// block flush policy, which cut blocks by block size (please refer to
|
||||
// `FlushBlockBySizePolicy`).
|
||||
std::shared_ptr<FlushBlockPolicyFactory> flush_block_policy_factory;
|
||||
};
|
||||
|
||||
BlockBasedTableFactory() : BlockBasedTableFactory(TableOptions()) { }
|
||||
BlockBasedTableFactory(const TableOptions& table_options):
|
||||
table_options_(table_options) {
|
||||
}
|
||||
|
||||
~BlockBasedTableFactory() {
|
||||
@ -58,7 +62,8 @@ public:
|
||||
override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<FlushBlockPolicyFactory> flush_block_policy_factory_;
|
||||
TableOptions table_options_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace rocksdb
|
||||
|
Loading…
Reference in New Issue
Block a user