Support "level_at_creation" in TablePropertiesCollectorFactory::Context (#8919)
Summary: Context: Exposing the level of the sst file (i.e, table) where it is created in `TablePropertiesCollectorFactory::Context` allows users of `TablePropertiesCollectorFactory` to customize some implementation details of `TablePropertiesCollectorFactory` and `TablePropertiesCollector` based on the level of creation. For example, `TablePropertiesCollector::NeedCompact()` can return different values based on level of creation. - Declared an extra field `level_at_creation` in `TablePropertiesCollectorFactory::Context` - Allowed `level_at_creation` to be passed in as an argument in `IntTblPropCollectorFactory::CreateIntTblPropCollector()` and `UserKeyTablePropertiesCollectorFactory::CreateIntTblPropCollector()`, the latter of which is an internal wrapper of user's passed-in `TablePropertiesCollectorFactory::CreateTablePropertiesCollector()` used in table-building process - Called `IntTblPropCollectorFactory::CreateIntTblPropCollector()` with `level_at_creation` passed into both `BlockBasedTableBuilder` and `PlainTableBuilder` - `PlainTableBuilder` previously did not capture `level_at_creation` from `TableBuilderOptions` in `PlainTableFactory`. In order for it to call the method with this parameter, this PR also made `PlainTableBuilder` capture `level_at_creation` as a required parameter - Called `IntTblPropCollectorFactory::CreateIntTblPropCollector()` with `level_at_creation` its overridden functions in its derived classes, including `RegularKeysStartWithAFactory::CreateIntTblPropCollector()` in `table_properties_collector_test.cc`, `SstFileWriterPropertiesCollectorFactory::CreateIntTblPropCollector()` in `sst_file_writer_collectors.h` Pull Request resolved: https://github.com/facebook/rocksdb/pull/8919 Test Plan: - Passed the added assertion for `context.level_at_creation` - Passed existing tests - Run `Make` to make sure adding a required parameter to `PlainTableBuilder`'s constructor does not break anything Reviewed By: anand1976 Differential Revision: D30951729 Pulled By: hx235 fbshipit-source-id: c4a0173b0d9344a4cf47e1b987d759c1c73cb474
This commit is contained in:
parent
7fd68b7c39
commit
d6bd1a0291
@ -48,6 +48,7 @@
|
|||||||
* Extended `FlushJobInfo` and `CompactionJobInfo` in listener.h to provide information about the blob files generated by a flush/compaction and garbage collected during compaction in Integrated BlobDB. Added struct members `blob_file_addition_infos` and `blob_file_garbage_infos` that contain this information.
|
* Extended `FlushJobInfo` and `CompactionJobInfo` in listener.h to provide information about the blob files generated by a flush/compaction and garbage collected during compaction in Integrated BlobDB. Added struct members `blob_file_addition_infos` and `blob_file_garbage_infos` that contain this information.
|
||||||
* Extended parameter `output_file_names` of `CompactFiles` API to also include paths of the blob files generated by the compaction in Integrated BlobDB.
|
* Extended parameter `output_file_names` of `CompactFiles` API to also include paths of the blob files generated by the compaction in Integrated BlobDB.
|
||||||
* Most `BackupEngine` functions now return `IOStatus` instead of `Status`. Most existing code should be compatible with this change but some calls might need to be updated.
|
* Most `BackupEngine` functions now return `IOStatus` instead of `Status`. Most existing code should be compatible with this change but some calls might need to be updated.
|
||||||
|
* Add a new field `level_at_creation` in `TablePropertiesCollectorFactory::Context` to capture the level at creating the SST file (i.e, table), of which the properties are being collected.
|
||||||
|
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
* Add a paranoid check where in case FileSystem layer doesn't fill the buffer but returns succeed, checksum is unlikely to match even if buffer contains a previous block. The byte modified is not useful anyway, so it isn't expected to change any behavior when FileSystem is satisfying its contract.
|
* Add a paranoid check where in case FileSystem layer doesn't fill the buffer but returns succeed, checksum is unlikely to match even if buffer contains a previous block. The byte modified is not useful anyway, so it isn't expected to change any behavior when FileSystem is satisfying its contract.
|
||||||
|
@ -42,7 +42,7 @@ class IntTblPropCollectorFactory {
|
|||||||
virtual ~IntTblPropCollectorFactory() {}
|
virtual ~IntTblPropCollectorFactory() {}
|
||||||
// has to be thread-safe
|
// has to be thread-safe
|
||||||
virtual IntTblPropCollector* CreateIntTblPropCollector(
|
virtual IntTblPropCollector* CreateIntTblPropCollector(
|
||||||
uint32_t column_family_id) = 0;
|
uint32_t column_family_id, int level_at_creation) = 0;
|
||||||
|
|
||||||
// The name of the properties collector can be used for debugging purpose.
|
// The name of the properties collector can be used for debugging purpose.
|
||||||
virtual const char* Name() const = 0;
|
virtual const char* Name() const = 0;
|
||||||
@ -92,9 +92,10 @@ class UserKeyTablePropertiesCollectorFactory
|
|||||||
std::shared_ptr<TablePropertiesCollectorFactory> user_collector_factory)
|
std::shared_ptr<TablePropertiesCollectorFactory> user_collector_factory)
|
||||||
: user_collector_factory_(user_collector_factory) {}
|
: user_collector_factory_(user_collector_factory) {}
|
||||||
virtual IntTblPropCollector* CreateIntTblPropCollector(
|
virtual IntTblPropCollector* CreateIntTblPropCollector(
|
||||||
uint32_t column_family_id) override {
|
uint32_t column_family_id, int level_at_creation) override {
|
||||||
TablePropertiesCollectorFactory::Context context;
|
TablePropertiesCollectorFactory::Context context;
|
||||||
context.column_family_id = column_family_id;
|
context.column_family_id = column_family_id;
|
||||||
|
context.level_at_creation = level_at_creation;
|
||||||
return new UserKeyTablePropertiesCollector(
|
return new UserKeyTablePropertiesCollector(
|
||||||
user_collector_factory_->CreateTablePropertiesCollector(context));
|
user_collector_factory_->CreateTablePropertiesCollector(context));
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ class TablePropertiesTest : public testing::Test,
|
|||||||
namespace {
|
namespace {
|
||||||
static const uint32_t kTestColumnFamilyId = 66;
|
static const uint32_t kTestColumnFamilyId = 66;
|
||||||
static const std::string kTestColumnFamilyName = "test_column_fam";
|
static const std::string kTestColumnFamilyName = "test_column_fam";
|
||||||
|
static const int kTestLevel = 1;
|
||||||
|
|
||||||
void MakeBuilder(
|
void MakeBuilder(
|
||||||
const Options& options, const ImmutableOptions& ioptions,
|
const Options& options, const ImmutableOptions& ioptions,
|
||||||
@ -51,11 +52,10 @@ void MakeBuilder(
|
|||||||
std::unique_ptr<FSWritableFile> wf(new test::StringSink);
|
std::unique_ptr<FSWritableFile> wf(new test::StringSink);
|
||||||
writable->reset(
|
writable->reset(
|
||||||
new WritableFileWriter(std::move(wf), "" /* don't care */, EnvOptions()));
|
new WritableFileWriter(std::move(wf), "" /* don't care */, EnvOptions()));
|
||||||
int unknown_level = -1;
|
|
||||||
TableBuilderOptions tboptions(
|
TableBuilderOptions tboptions(
|
||||||
ioptions, moptions, internal_comparator, int_tbl_prop_collector_factories,
|
ioptions, moptions, internal_comparator, int_tbl_prop_collector_factories,
|
||||||
options.compression, options.compression_opts, kTestColumnFamilyId,
|
options.compression, options.compression_opts, kTestColumnFamilyId,
|
||||||
kTestColumnFamilyName, unknown_level);
|
kTestColumnFamilyName, kTestLevel);
|
||||||
builder->reset(NewTableBuilder(tboptions, writable->get()));
|
builder->reset(NewTableBuilder(tboptions, writable->get()));
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -199,6 +199,7 @@ class RegularKeysStartWithAFactory : public IntTblPropCollectorFactory,
|
|||||||
TablePropertiesCollector* CreateTablePropertiesCollector(
|
TablePropertiesCollector* CreateTablePropertiesCollector(
|
||||||
TablePropertiesCollectorFactory::Context context) override {
|
TablePropertiesCollectorFactory::Context context) override {
|
||||||
EXPECT_EQ(kTestColumnFamilyId, context.column_family_id);
|
EXPECT_EQ(kTestColumnFamilyId, context.column_family_id);
|
||||||
|
EXPECT_EQ(kTestLevel, context.level_at_creation);
|
||||||
if (!backward_mode_) {
|
if (!backward_mode_) {
|
||||||
return new RegularKeysStartWithA();
|
return new RegularKeysStartWithA();
|
||||||
} else {
|
} else {
|
||||||
@ -206,7 +207,7 @@ class RegularKeysStartWithAFactory : public IntTblPropCollectorFactory,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
IntTblPropCollector* CreateIntTblPropCollector(
|
IntTblPropCollector* CreateIntTblPropCollector(
|
||||||
uint32_t /*column_family_id*/) override {
|
uint32_t /*column_family_id*/, int /* level_at_creation */) override {
|
||||||
return new RegularKeysStartWithAInternal();
|
return new RegularKeysStartWithAInternal();
|
||||||
}
|
}
|
||||||
const char* Name() const override { return "RegularKeysStartWithA"; }
|
const char* Name() const override { return "RegularKeysStartWithA"; }
|
||||||
|
@ -137,7 +137,11 @@ class TablePropertiesCollectorFactory : public Customizable {
|
|||||||
public:
|
public:
|
||||||
struct Context {
|
struct Context {
|
||||||
uint32_t column_family_id;
|
uint32_t column_family_id;
|
||||||
|
// The level at creating the SST file (i.e, table), of which the
|
||||||
|
// properties are being collected.
|
||||||
|
int level_at_creation = kUnknownLevelAtCreation;
|
||||||
static const uint32_t kUnknownColumnFamily;
|
static const uint32_t kUnknownColumnFamily;
|
||||||
|
static const int kUnknownLevelAtCreation = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~TablePropertiesCollectorFactory() {}
|
virtual ~TablePropertiesCollectorFactory() {}
|
||||||
|
@ -507,7 +507,8 @@ struct BlockBasedTableBuilder::Rep {
|
|||||||
assert(factory);
|
assert(factory);
|
||||||
|
|
||||||
table_properties_collectors.emplace_back(
|
table_properties_collectors.emplace_back(
|
||||||
factory->CreateIntTblPropCollector(tbo.column_family_id));
|
factory->CreateIntTblPropCollector(tbo.column_family_id,
|
||||||
|
tbo.level_at_creation));
|
||||||
}
|
}
|
||||||
table_properties_collectors.emplace_back(
|
table_properties_collectors.emplace_back(
|
||||||
new BlockBasedTablePropertiesCollector(
|
new BlockBasedTablePropertiesCollector(
|
||||||
|
@ -59,8 +59,8 @@ extern const uint64_t kLegacyPlainTableMagicNumber = 0x4f3418eb7a8f13b8ull;
|
|||||||
PlainTableBuilder::PlainTableBuilder(
|
PlainTableBuilder::PlainTableBuilder(
|
||||||
const ImmutableOptions& ioptions, const MutableCFOptions& moptions,
|
const ImmutableOptions& ioptions, const MutableCFOptions& moptions,
|
||||||
const IntTblPropCollectorFactories* int_tbl_prop_collector_factories,
|
const IntTblPropCollectorFactories* int_tbl_prop_collector_factories,
|
||||||
uint32_t column_family_id, WritableFileWriter* file, uint32_t user_key_len,
|
uint32_t column_family_id, int level_at_creation, WritableFileWriter* file,
|
||||||
EncodingType encoding_type, size_t index_sparseness,
|
uint32_t user_key_len, EncodingType encoding_type, size_t index_sparseness,
|
||||||
uint32_t bloom_bits_per_key, const std::string& column_family_name,
|
uint32_t bloom_bits_per_key, const std::string& column_family_name,
|
||||||
uint32_t num_probes, size_t huge_page_tlb_size, double hash_table_ratio,
|
uint32_t num_probes, size_t huge_page_tlb_size, double hash_table_ratio,
|
||||||
bool store_index_in_file, const std::string& db_id,
|
bool store_index_in_file, const std::string& db_id,
|
||||||
@ -119,7 +119,8 @@ PlainTableBuilder::PlainTableBuilder(
|
|||||||
assert(factory);
|
assert(factory);
|
||||||
|
|
||||||
table_properties_collectors_.emplace_back(
|
table_properties_collectors_.emplace_back(
|
||||||
factory->CreateIntTblPropCollector(column_family_id));
|
factory->CreateIntTblPropCollector(column_family_id,
|
||||||
|
level_at_creation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,13 +39,14 @@ class PlainTableBuilder: public TableBuilder {
|
|||||||
PlainTableBuilder(
|
PlainTableBuilder(
|
||||||
const ImmutableOptions& ioptions, const MutableCFOptions& moptions,
|
const ImmutableOptions& ioptions, const MutableCFOptions& moptions,
|
||||||
const IntTblPropCollectorFactories* int_tbl_prop_collector_factories,
|
const IntTblPropCollectorFactories* int_tbl_prop_collector_factories,
|
||||||
uint32_t column_family_id, WritableFileWriter* file,
|
uint32_t column_family_id, int level_at_creation,
|
||||||
uint32_t user_key_size, EncodingType encoding_type,
|
WritableFileWriter* file, uint32_t user_key_size,
|
||||||
size_t index_sparseness, uint32_t bloom_bits_per_key,
|
EncodingType encoding_type, size_t index_sparseness,
|
||||||
const std::string& column_family_name, uint32_t num_probes = 6,
|
uint32_t bloom_bits_per_key, const std::string& column_family_name,
|
||||||
size_t huge_page_tlb_size = 0, double hash_table_ratio = 0,
|
uint32_t num_probes = 6, size_t huge_page_tlb_size = 0,
|
||||||
bool store_index_in_file = false, const std::string& db_id = "",
|
double hash_table_ratio = 0, bool store_index_in_file = false,
|
||||||
const std::string& db_session_id = "", uint64_t file_number = 0);
|
const std::string& db_id = "", const std::string& db_session_id = "",
|
||||||
|
uint64_t file_number = 0);
|
||||||
// No copying allowed
|
// No copying allowed
|
||||||
PlainTableBuilder(const PlainTableBuilder&) = delete;
|
PlainTableBuilder(const PlainTableBuilder&) = delete;
|
||||||
void operator=(const PlainTableBuilder&) = delete;
|
void operator=(const PlainTableBuilder&) = delete;
|
||||||
|
@ -80,9 +80,10 @@ TableBuilder* PlainTableFactory::NewTableBuilder(
|
|||||||
return new PlainTableBuilder(
|
return new PlainTableBuilder(
|
||||||
table_builder_options.ioptions, table_builder_options.moptions,
|
table_builder_options.ioptions, table_builder_options.moptions,
|
||||||
table_builder_options.int_tbl_prop_collector_factories,
|
table_builder_options.int_tbl_prop_collector_factories,
|
||||||
table_builder_options.column_family_id, file, table_options_.user_key_len,
|
table_builder_options.column_family_id,
|
||||||
table_options_.encoding_type, table_options_.index_sparseness,
|
table_builder_options.level_at_creation, file,
|
||||||
table_options_.bloom_bits_per_key,
|
table_options_.user_key_len, table_options_.encoding_type,
|
||||||
|
table_options_.index_sparseness, table_options_.bloom_bits_per_key,
|
||||||
table_builder_options.column_family_name, 6,
|
table_builder_options.column_family_name, 6,
|
||||||
table_options_.huge_page_tlb_size, table_options_.hash_table_ratio,
|
table_options_.huge_page_tlb_size, table_options_.hash_table_ratio,
|
||||||
table_options_.store_index_in_file, table_builder_options.db_id,
|
table_options_.store_index_in_file, table_builder_options.db_id,
|
||||||
|
@ -78,7 +78,7 @@ class SstFileWriterPropertiesCollectorFactory
|
|||||||
: version_(version), global_seqno_(global_seqno) {}
|
: version_(version), global_seqno_(global_seqno) {}
|
||||||
|
|
||||||
virtual IntTblPropCollector* CreateIntTblPropCollector(
|
virtual IntTblPropCollector* CreateIntTblPropCollector(
|
||||||
uint32_t /*column_family_id*/) override {
|
uint32_t /*column_family_id*/, int /* level_at_creation */) override {
|
||||||
return new SstFileWriterPropertiesCollector(version_, global_seqno_);
|
return new SstFileWriterPropertiesCollector(version_, global_seqno_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user