diff --git a/table/block_based_table_factory.cc b/table/block_based_table_factory.cc index 43734ea71..836f6edf6 100644 --- a/table/block_based_table_factory.cc +++ b/table/block_based_table_factory.cc @@ -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; } diff --git a/table/block_based_table_factory.h b/table/block_based_table_factory.h index d6ead29a0..ee525816f 100644 --- a/table/block_based_table_factory.h +++ b/table/block_based_table_factory.h @@ -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 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 flush_block_policy_factory_; + TableOptions table_options_; }; + } // namespace rocksdb