Coverage Report

Created: 2026-11-04 15:01

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