Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
hx235 committed Nov 7, 2023
1 parent 16ae354 commit de3bb39
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 36 deletions.
15 changes: 4 additions & 11 deletions table/block_based/block_based_table_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1710,9 +1710,9 @@ void BlockBasedTableBuilder::WritePropertiesBlock(
property_block_builder.AddTableProperty(rep_->props);

// Add use collected properties
NotifyCollectTableCollectorsOnFinish(rep_->table_properties_collectors,
rep_->ioptions.logger,
&property_block_builder);
NotifyCollectTableCollectorsOnFinish(
rep_->table_properties_collectors, rep_->ioptions.logger,
&property_block_builder, &(rep_->props));

Slice block_data = property_block_builder.Finish();
TEST_SYNC_POINT_CALLBACK(
Expand Down Expand Up @@ -2061,14 +2061,7 @@ bool BlockBasedTableBuilder::NeedCompact() const {
}

TableProperties BlockBasedTableBuilder::GetTableProperties() const {
TableProperties ret = rep_->props;
for (const auto& collector : rep_->table_properties_collectors) {
for (const auto& prop : collector->GetReadableProperties()) {
ret.readable_properties.insert(prop);
}
collector->Finish(&ret.user_collected_properties).PermitUncheckedError();
}
return ret;
return rep_->props;
}

std::string BlockBasedTableBuilder::GetFileChecksum() const {
Expand Down
21 changes: 12 additions & 9 deletions table/meta_blocks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,24 @@ void NotifyCollectTableCollectorsOnBlockAdd(

bool NotifyCollectTableCollectorsOnFinish(
const std::vector<std::unique_ptr<IntTblPropCollector>>& collectors,
Logger* info_log, PropertyBlockBuilder* builder) {
Logger* info_log, PropertyBlockBuilder* builder, TableProperties* props) {
assert(props);
bool all_succeeded = true;
for (auto& collector : collectors) {
UserCollectedProperties user_collected_properties;
Status s = collector->Finish(&user_collected_properties);

all_succeeded = all_succeeded && s.ok();
if (!s.ok()) {
Status s = collector->Finish(&props->user_collected_properties);
if (s.ok()) {
for (const auto& prop : collector->GetReadableProperties()) {
props->readable_properties.insert(prop);
}
builder->Add(props->user_collected_properties);
} else {
LogPropertiesCollectionError(info_log, "Finish" /* method */,
collector->Name());
} else {
builder->Add(user_collected_properties);
if (all_succeeded) {
all_succeeded = false;
}
}
}

return all_succeeded;
}

Expand Down
2 changes: 1 addition & 1 deletion table/meta_blocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void NotifyCollectTableCollectorsOnBlockAdd(
// property collectors. The collected properties will be added to `builder`.
bool NotifyCollectTableCollectorsOnFinish(
const std::vector<std::unique_ptr<IntTblPropCollector>>& collectors,
Logger* info_log, PropertyBlockBuilder* builder);
Logger* info_log, PropertyBlockBuilder* builder, TableProperties* props);

// Read table properties from a file using known BlockHandle.
// @returns a status to indicate if the operation succeeded. On success,
Expand Down
7 changes: 3 additions & 4 deletions table/plain/plain_table_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,10 @@ Status PlainTableBuilder::Finish() {
// -- Add basic properties
property_block_builder.AddTableProperty(properties_);

property_block_builder.Add(properties_.user_collected_properties);

// -- Add user collected properties
NotifyCollectTableCollectorsOnFinish(
table_properties_collectors_, ioptions_.logger, &property_block_builder);
NotifyCollectTableCollectorsOnFinish(table_properties_collectors_,
ioptions_.logger,
&property_block_builder, &properties_);

// -- Write property block
BlockHandle property_block_handle;
Expand Down
12 changes: 1 addition & 11 deletions table/plain/plain_table_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,7 @@ class PlainTableBuilder : public TableBuilder {
// Finish() call, returns the size of the final generated file.
uint64_t FileSize() const override;

TableProperties GetTableProperties() const override {
TableProperties ret = properties_;
for (const auto& collector : table_properties_collectors_) {
for (const auto& prop : collector->GetReadableProperties()) {
ret.readable_properties.insert(prop);
}
collector->Finish(&ret.user_collected_properties).PermitUncheckedError();
}
return ret;
}
TableProperties GetTableProperties() const override { return properties_; }

bool SaveIndexInFile() const { return store_index_in_file_; }

Expand Down Expand Up @@ -158,4 +149,3 @@ class PlainTableBuilder : public TableBuilder {
};

} // namespace ROCKSDB_NAMESPACE

0 comments on commit de3bb39

Please sign in to comment.