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(
|
TableBuilder* BlockBasedTableFactory::GetTableBuilder(
|
||||||
const Options& options, WritableFile* file,
|
const Options& options, WritableFile* file,
|
||||||
CompressionType compression_type) const {
|
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
|
// if flush block policy factory is not set, we'll create the default one
|
||||||
// from the options.
|
// from the options.
|
||||||
@ -54,7 +55,8 @@ TableBuilder* BlockBasedTableFactory::GetTableBuilder(
|
|||||||
// options.
|
// options.
|
||||||
// We can safely delete flush_block_policy_factory since it will only be used
|
// We can safely delete flush_block_policy_factory since it will only be used
|
||||||
// during the construction of `BlockBasedTableBuilder`.
|
// 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;
|
delete flush_block_policy_factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,14 +31,18 @@ class BlockBasedTableBuilder;
|
|||||||
|
|
||||||
class BlockBasedTableFactory: public TableFactory {
|
class BlockBasedTableFactory: public TableFactory {
|
||||||
public:
|
public:
|
||||||
// @flush_block_policy_factory creates the instances of flush block policy.
|
struct TableOptions {
|
||||||
// which provides a configurable way to determine when to flush a block in
|
// @flush_block_policy_factory creates the instances of flush block policy.
|
||||||
// the block based tables. If not set, table builder will use the default
|
// which provides a configurable way to determine when to flush a block in
|
||||||
// block flush policy, which cut blocks by block size (please refer to
|
// the block based tables. If not set, table builder will use the default
|
||||||
// `FlushBlockBySizePolicy`).
|
// block flush policy, which cut blocks by block size (please refer to
|
||||||
BlockBasedTableFactory(
|
// `FlushBlockBySizePolicy`).
|
||||||
FlushBlockPolicyFactory* flush_block_policy_factory = nullptr) :
|
std::shared_ptr<FlushBlockPolicyFactory> flush_block_policy_factory;
|
||||||
flush_block_policy_factory_(flush_block_policy_factory) {
|
};
|
||||||
|
|
||||||
|
BlockBasedTableFactory() : BlockBasedTableFactory(TableOptions()) { }
|
||||||
|
BlockBasedTableFactory(const TableOptions& table_options):
|
||||||
|
table_options_(table_options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
~BlockBasedTableFactory() {
|
~BlockBasedTableFactory() {
|
||||||
@ -58,7 +62,8 @@ public:
|
|||||||
override;
|
override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<FlushBlockPolicyFactory> flush_block_policy_factory_;
|
TableOptions table_options_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace rocksdb
|
} // namespace rocksdb
|
||||||
|
Loading…
x
Reference in New Issue
Block a user