Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ProcessManifestWrites a little bit #7751

Closed
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 13 additions & 23 deletions db/version_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4229,31 +4229,21 @@ Status VersionSet::ProcessManifestWrites(
// Each version in versions corresponds to a column family.
// For each column family, update its log number indicating that logs
// with number smaller than this should be ignored.
// TODO (yanqin): remove the nested loop if possible.
for (const auto version : versions) {
uint64_t max_log_number_in_batch = 0;
assert(version->cfd_);
uint32_t cf_id = version->cfd_->GetID();
std::string full_history_ts_low;
for (const auto& e : batch_edits) {
if (e->column_family_ == cf_id) {
if (e->has_log_number_) {
max_log_number_in_batch =
std::max(max_log_number_in_batch, e->log_number_);
}
if (e->HasFullHistoryTsLow()) {
version->cfd_->SetFullHistoryTsLow(e->GetFullHistoryTsLow());
}
}
uint64_t last_min_log_number_to_keep = 0;
for (const auto& e : batch_edits) {
ColumnFamilyData* cfd = nullptr;
if (!e->IsColumnFamilyManipulation()) {
cfd = column_family_set_->GetColumnFamily(e->column_family_);
assert(!cfd || !cfd->IsDropped());
}
if (max_log_number_in_batch != 0) {
assert(version->cfd_->GetLogNumber() <= max_log_number_in_batch);
version->cfd_->SetLogNumber(max_log_number_in_batch);
if (cfd) {
if (e->has_log_number_ && e->log_number_ > cfd->GetLogNumber()) {
cfd->SetLogNumber(e->log_number_);
}
if (e->HasFullHistoryTsLow()) {
cfd->SetFullHistoryTsLow(e->GetFullHistoryTsLow());
}
}
}

uint64_t last_min_log_number_to_keep = 0;
for (auto& e : batch_edits) {
if (e->has_min_log_number_to_keep_) {
last_min_log_number_to_keep =
std::max(last_min_log_number_to_keep, e->min_log_number_to_keep_);
Expand Down