Coverage Report

Created: 2026-08-18 18:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/cloud/cloud_cumulative_compaction.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <limits>
21
#include <memory>
22
#include <optional>
23
24
#include "cloud/cloud_storage_engine.h"
25
#include "cloud/cloud_tablet.h"
26
#include "storage/compaction/compaction.h"
27
#include "storage/compaction_task_tracker.h"
28
29
namespace doris {
30
31
class CloudCumulativeCompaction : public CloudCompactionMixin {
32
public:
33
    CloudCumulativeCompaction(CloudStorageEngine& engine, CloudTabletSPtr tablet);
34
35
    ~CloudCumulativeCompaction() override;
36
37
    Status prepare_compact() override;
38
    Status execute_compact() override;
39
    Status request_global_lock();
40
41
0
    std::optional<CompactionProfileType> profile_type() const override {
42
0
        return CompactionProfileType::CUMULATIVE;
43
0
    }
44
0
    int64_t input_segments_num_value() const override { return _input_segments; }
45
46
    void do_lease();
47
48
0
    int64_t get_input_rowsets_bytes() const { return _input_rowsets_total_size; }
49
0
    int64_t get_input_num_rows() const { return _input_row_num; }
50
51
private:
52
    Status advance_cumulative_point_before_pick(int64_t min_conflict_version);
53
54
    Status pick_rowsets_to_compact();
55
56
0
    std::string_view compaction_name() const override { return "CloudCumulativeCompaction"; }
57
58
protected:
59
    Status modify_rowsets() override;
60
61
private:
62
    Status garbage_collection() override;
63
64
    void update_cumulative_point(int64_t input_cumulative_point, int64_t output_cumulative_point);
65
66
0
    ReaderType compaction_type() const override { return ReaderType::READER_CUMULATIVE_COMPACTION; }
67
68
    int64_t _input_segments = 0;
69
    // A task must use one execution mode even if the dynamic config changes while it is running.
70
    const bool _enable_parallel_cumu_compaction;
71
    int64_t _min_conflict_version = std::numeric_limits<int64_t>::max();
72
    int64_t _max_conflict_version = 0;
73
    // Snapshot values when pick input rowsets
74
    int64_t _base_compaction_cnt = 0;
75
    int64_t _cumulative_compaction_cnt = 0;
76
    int64_t _picked_cumulative_point = 0;
77
    Version _last_delete_version {-1, -1};
78
};
79
80
} // namespace doris