csun5285 commented on code in PR #20715: URL: https://github.com/apache/doris/pull/20715#discussion_r1228012530
########## be/src/olap/cumulative_compaction_time_series_policy.cpp: ########## @@ -0,0 +1,255 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "olap/cumulative_compaction_time_series_policy.h" + +#include "common/logging.h" +#include "olap/tablet.h" +#include "util/time.h" +namespace doris { + +TimeSeriesCumulativeCompactionPolicy::TimeSeriesCumulativeCompactionPolicy( + int64_t compaction_goal_size, int64_t compaction_file_count_threshold, + int64_t compaction_time_threshold_seconds) + : _compaction_goal_size(compaction_goal_size), + _compaction_file_count_threshold(compaction_file_count_threshold), + _compaction_time_threshold_seconds(compaction_time_threshold_seconds) {} + +uint32_t TimeSeriesCumulativeCompactionPolicy::calc_cumulative_compaction_score(Tablet* tablet) { + uint32_t score = 0; + bool base_rowset_exist = false; + const int64_t point = tablet->cumulative_layer_point(); + + int64_t total_size = 0; + RowsetMetaSharedPtr first_meta; + int64_t first_version = INT64_MAX; + // NOTE: tablet._meta_lock is hold + auto& rs_metas = tablet->tablet_meta()->all_rs_metas(); + // check the base rowset and collect the rowsets of cumulative part + for (auto& rs_meta : rs_metas) { + if (rs_meta->start_version() < first_version) { + first_version = rs_meta->start_version(); + first_meta = rs_meta; + } + // check base rowset + if (rs_meta->start_version() == 0) { + base_rowset_exist = true; + } + if (rs_meta->end_version() < point || !rs_meta->is_local()) { Review Comment: Base and cumulative compaction will only merge rowsets where the condition is_local() == true, cold data compaction will only merge rowsets where is_local() == false -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org