Coverage Report

Created: 2026-03-12 16:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/cloud/cloud_index_change_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 <memory>
21
22
#include "cloud/cloud_storage_engine.h"
23
#include "cloud/cloud_tablet.h"
24
#include "storage/compaction/compaction.h"
25
26
namespace doris {
27
28
class CloudIndexChangeCompaction : public CloudCompactionMixin {
29
public:
30
    CloudIndexChangeCompaction(CloudStorageEngine& engine, CloudTabletSPtr tablet,
31
                               int32_t schema_version, std::vector<TOlapTableIndex>& index_list,
32
                               std::vector<TColumn>& columns);
33
34
    ~CloudIndexChangeCompaction();
35
36
    Status prepare_compact() override;
37
    Status execute_compact() override;
38
    Status request_global_lock(bool& should_skip_err);
39
40
    void do_lease();
41
42
507
    bool is_finish_index_change() { return _input_rowsets.size() == 0; }
43
44
1.16k
    bool is_index_change_compaction() override { return true; }
45
46
3.58k
    bool is_base_compaction() const { return _compact_type == cloud::TabletCompactionJobPB::BASE; }
47
48
    Status rebuild_tablet_schema() override;
49
50
private:
51
    void _update_tablet_for_cumu_compaction(cloud::FinishTabletJobResponse resp,
52
                                            DeleteBitmapPtr output_rowset_delete_bitmap);
53
    void _update_tablet_for_base_compaction(cloud::FinishTabletJobResponse resp,
54
                                            DeleteBitmapPtr output_rowset_delete_bitmap);
55
56
protected:
57
504
    std::string_view compaction_name() const override { return "CloudIndexChangeCompaction"; }
58
59
    // if cumu rowset is modified, cumu compaction should sync rowset before execute.
60
    // if base rowset is modified, base compaction should sync rowset before execute.
61
2.05k
    ReaderType compaction_type() const override {
62
2.05k
        return is_base_compaction() ? ReaderType::READER_BASE_COMPACTION
63
2.05k
                                    : ReaderType::READER_CUMULATIVE_COMPACTION;
64
2.05k
    }
65
66
    Status modify_rowsets() override;
67
68
    Status garbage_collection() override;
69
70
    int32_t _schema_version;
71
72
    std::vector<TOlapTableIndex>& _index_list;
73
74
    std::vector<TColumn>& _columns;
75
76
    cloud::TabletCompactionJobPB::CompactionType _compact_type;
77
78
    int64_t _base_compaction_cnt {0};
79
    int64_t _cumulative_compaction_cnt {0};
80
81
    int64_t _input_segments {0};
82
83
    TabletSchemaSPtr _final_tablet_schema = nullptr;
84
};
85
86
}; // namespace doris