Change order of parameters in adaptive table factory
Summary: This is minor, but if we put the writing talbe factory as the third parameter, when we add a new table format, we'll have a situation: 1) block based factory 2) plain table factory 3) output factory 4) new format factory I think it makes more sense to have output as the first parameter. Also, fixed a NewAdaptiveTableFactory() call in unit test Test Plan: unit test Reviewers: sdong Reviewed By: sdong Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D19119
This commit is contained in:
parent
8c265c08f1
commit
3525aac9e5
@ -862,8 +862,10 @@ TEST(PlainTableDBTest, AdaptiveTable) {
|
||||
|
||||
options.create_if_missing = false;
|
||||
std::shared_ptr<TableFactory> dummy_factory;
|
||||
options.table_factory.reset(
|
||||
NewAdaptiveTableFactory(dummy_factory, dummy_factory, false));
|
||||
std::shared_ptr<TableFactory> block_based_factory(
|
||||
NewBlockBasedTableFactory());
|
||||
options.table_factory.reset(NewAdaptiveTableFactory(
|
||||
block_based_factory, dummy_factory, dummy_factory));
|
||||
Reopen(&options);
|
||||
ASSERT_EQ("v3", Get("1000000000000foo"));
|
||||
ASSERT_EQ("v2", Get("0000000000000bar"));
|
||||
|
@ -207,14 +207,14 @@ class TableFactory {
|
||||
// Create a special table factory that can open both of block based table format
|
||||
// and plain table, based on setting inside the SST files. It should be used to
|
||||
// convert a DB from one table format to another.
|
||||
// @table_factory_to_write: the table factory used when writing to new files.
|
||||
// @block_based_table_factory: block based table factory to use. If NULL, use
|
||||
// a default one.
|
||||
// @plain_table_factory: plain table factory to use. If NULL, use a default one.
|
||||
// @table_factory_to_write: the table factory used when writing to new files.
|
||||
extern TableFactory* NewAdaptiveTableFactory(
|
||||
std::shared_ptr<TableFactory> table_factory_to_write = nullptr,
|
||||
std::shared_ptr<TableFactory> block_based_table_factory = nullptr,
|
||||
std::shared_ptr<TableFactory> plain_table_factory = nullptr,
|
||||
std::shared_ptr<TableFactory> table_factory_to_write = nullptr);
|
||||
std::shared_ptr<TableFactory> plain_table_factory = nullptr);
|
||||
|
||||
#endif // ROCKSDB_LITE
|
||||
|
||||
|
@ -10,21 +10,21 @@
|
||||
namespace rocksdb {
|
||||
|
||||
AdaptiveTableFactory::AdaptiveTableFactory(
|
||||
std::shared_ptr<TableFactory> table_factory_to_write,
|
||||
std::shared_ptr<TableFactory> block_based_table_factory,
|
||||
std::shared_ptr<TableFactory> plain_table_factory,
|
||||
std::shared_ptr<TableFactory> table_factory_to_write)
|
||||
: block_based_table_factory_(block_based_table_factory),
|
||||
plain_table_factory_(plain_table_factory),
|
||||
table_factory_to_write_(table_factory_to_write) {
|
||||
std::shared_ptr<TableFactory> plain_table_factory)
|
||||
: table_factory_to_write_(table_factory_to_write),
|
||||
block_based_table_factory_(block_based_table_factory),
|
||||
plain_table_factory_(plain_table_factory) {
|
||||
if (!table_factory_to_write_) {
|
||||
table_factory_to_write_ = block_based_table_factory_;
|
||||
}
|
||||
if (!plain_table_factory_) {
|
||||
plain_table_factory_.reset(NewPlainTableFactory());
|
||||
}
|
||||
if (!block_based_table_factory_) {
|
||||
block_based_table_factory_.reset(NewBlockBasedTableFactory());
|
||||
}
|
||||
if (!table_factory_to_write_) {
|
||||
table_factory_to_write_ = block_based_table_factory_;
|
||||
}
|
||||
}
|
||||
|
||||
extern const uint64_t kPlainTableMagicNumber;
|
||||
@ -62,11 +62,11 @@ TableBuilder* AdaptiveTableFactory::NewTableBuilder(
|
||||
}
|
||||
|
||||
extern TableFactory* NewAdaptiveTableFactory(
|
||||
std::shared_ptr<TableFactory> table_factory_to_write,
|
||||
std::shared_ptr<TableFactory> block_based_table_factory,
|
||||
std::shared_ptr<TableFactory> plain_table_factory,
|
||||
std::shared_ptr<TableFactory> table_factory_to_write) {
|
||||
std::shared_ptr<TableFactory> plain_table_factory) {
|
||||
return new AdaptiveTableFactory(
|
||||
block_based_table_factory, plain_table_factory, table_factory_to_write);
|
||||
table_factory_to_write, block_based_table_factory, plain_table_factory);
|
||||
}
|
||||
|
||||
} // namespace rocksdb
|
||||
|
@ -26,9 +26,9 @@ class AdaptiveTableFactory : public TableFactory {
|
||||
~AdaptiveTableFactory() {}
|
||||
|
||||
explicit AdaptiveTableFactory(
|
||||
std::shared_ptr<TableFactory> table_factory_to_write,
|
||||
std::shared_ptr<TableFactory> block_based_table_factory,
|
||||
std::shared_ptr<TableFactory> plain_table_factory,
|
||||
std::shared_ptr<TableFactory> table_factory_to_write);
|
||||
std::shared_ptr<TableFactory> plain_table_factory);
|
||||
const char* Name() const override { return "AdaptiveTableFactory"; }
|
||||
Status NewTableReader(const Options& options, const EnvOptions& soptions,
|
||||
const InternalKeyComparator& internal_comparator,
|
||||
@ -41,9 +41,9 @@ class AdaptiveTableFactory : public TableFactory {
|
||||
override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<TableFactory> table_factory_to_write_;
|
||||
std::shared_ptr<TableFactory> block_based_table_factory_;
|
||||
std::shared_ptr<TableFactory> plain_table_factory_;
|
||||
std::shared_ptr<TableFactory> table_factory_to_write_;
|
||||
};
|
||||
|
||||
} // namespace rocksdb
|
||||
|
Loading…
Reference in New Issue
Block a user