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

Take segments in singleton rowset into consideration upon cumulative compaction #1866

Merged
merged 1 commit into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 12 additions & 4 deletions be/src/olap/cumulative_compaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,37 @@ OLAPStatus CumulativeCompaction::pick_rowsets_to_compact() {
RETURN_NOT_OK(check_version_continuity(candidate_rowsets));

std::vector<RowsetSharedPtr> transient_rowsets;
size_t num_overlapping_segments = 0;
for (size_t i = 0; i < candidate_rowsets.size() - 1; ++i) {
// VersionHash will calculated from chosen rowsets.
// If ultimate singleton rowset is chosen, VersionHash
// will be different from the value recorded in FE.
// So the ultimate singleton rowset is revserved.
RowsetSharedPtr rowset = candidate_rowsets[i];
if (_tablet->version_for_delete_predicate(rowset->version())) {
if (transient_rowsets.size() > config::min_cumulative_compaction_num_singleton_deltas) {
if (num_overlapping_segments >= config::min_cumulative_compaction_num_singleton_deltas) {
_input_rowsets = transient_rowsets;
break;
}
transient_rowsets.clear();
num_overlapping_segments = 0;
continue;
}

if (transient_rowsets.size() >= config::max_cumulative_compaction_num_singleton_deltas) {
if (num_overlapping_segments >= config::max_cumulative_compaction_num_singleton_deltas) {
// the threshold of files to compacted one time
break;
}

if (rowset->start_version() == rowset->end_version()) {
num_overlapping_segments += rowset->num_segments();
} else {
num_overlapping_segments++;
}
transient_rowsets.push_back(rowset);
}

if (transient_rowsets.size() > config::min_cumulative_compaction_num_singleton_deltas) {
if (num_overlapping_segments >= config::min_cumulative_compaction_num_singleton_deltas) {
_input_rowsets = transient_rowsets;
}

Expand All @@ -113,7 +121,7 @@ OLAPStatus CumulativeCompaction::pick_rowsets_to_compact() {

if (_input_rowsets.size() <= 1) {
LOG(WARNING) << "There is no enough rowsets to cumulative compaction."
<< ", the size of rowsets to compact=" << candidate_rowsets.size()
<< " The size of rowsets to compact=" << candidate_rowsets.size()
<< ", cumulative_point=" << _tablet->cumulative_layer_point();
return OLAP_ERR_CUMULATIVE_NO_SUITABLE_VERSIONS;
}
Expand Down
156 changes: 0 additions & 156 deletions be/src/olap/olap_header.h

This file was deleted.

3 changes: 3 additions & 0 deletions be/src/olap/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,9 @@ const uint32_t Tablet::calc_cumulative_compaction_score() const {
if (rs_meta->start_version() >= point) {
score++;
}
if (rs_meta->start_version() == rs_meta->end_version()) {
score += rs_meta->num_segments();
}
if (rs_meta->start_version() == 0) {
base_rowset_exist = true;
}
Expand Down