Coverage Report

Created: 2026-09-30 14:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/rowset/beta_rowset.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
#ifndef DORIS_SRC_OLAP_ROWSET_BETA_ROWSET_H_
19
#define DORIS_SRC_OLAP_ROWSET_BETA_ROWSET_H_
20
21
#include <stddef.h>
22
23
#include <atomic>
24
#include <cstdint>
25
#include <memory>
26
#include <mutex>
27
#include <string>
28
#include <vector>
29
30
#include "common/status.h"
31
#include "storage/olap_common.h"
32
#include "storage/rowset/rowset.h"
33
#include "storage/rowset/rowset_meta.h"
34
#include "storage/rowset/rowset_reader.h"
35
#include "storage/segment/segment.h"
36
#include "storage/tablet/tablet_schema.h"
37
38
namespace doris {
39
40
class BetaRowset;
41
42
namespace io {
43
struct IOContext;
44
class RemoteFileSystem;
45
} // namespace io
46
struct RowsetId;
47
48
using BetaRowsetSharedPtr = std::shared_ptr<BetaRowset>;
49
50
class BetaRowset final : public Rowset {
51
public:
52
    ~BetaRowset() override;
53
54
    Status create_reader(RowsetReaderSharedPtr* result) override;
55
56
    // Return the absolute path of local segcompacted segment file
57
    static std::string local_segment_path_segcompacted(const std::string& tablet_path,
58
                                                       const RowsetId& rowset_id, int64_t begin,
59
                                                       int64_t end);
60
61
    Status remove() override;
62
63
    Status link_files_to(const std::string& dir, RowsetId new_rowset_id,
64
                         size_t new_rowset_start_seg_id = 0,
65
                         std::set<int64_t>* without_index_uids = nullptr) override;
66
67
    Status copy_files_to(const std::string& dir, const RowsetId& new_rowset_id) override;
68
69
    Status upload_to(const StorageResource& dest_fs, const RowsetId& new_rowset_id) override;
70
71
    // only applicable to alpha rowset, no op here
72
0
    Status remove_old_files(std::vector<std::string>* files_to_remove) override {
73
0
        return Status::OK();
74
0
    }
75
76
    Status check_file_exist() override;
77
78
    Status load_segments(std::vector<segment_v2::SegmentSharedPtr>* segments);
79
80
    Status load_segment(int64_t seg_id, OlapReaderStatistics* read_stats,
81
                        segment_v2::SegmentSharedPtr* segment,
82
                        const io::IOContext* io_ctx = nullptr);
83
84
    Status load_segment(RowsetSegmentRef seg, OlapReaderStatistics* read_stats,
85
                        segment_v2::SegmentSharedPtr* segment,
86
                        const io::IOContext* io_ctx = nullptr);
87
88
    Status get_segments_size(std::vector<size_t>* segments_size);
89
90
    Status get_inverted_index_size(int64_t* index_size) override;
91
92
    [[nodiscard]] virtual Status add_to_binlog() override;
93
94
    Status calc_file_crc(uint32_t* crc_value, int64_t* file_count);
95
96
    Status show_nested_index_file(rapidjson::Value* rowset_value,
97
                                  rapidjson::Document::AllocatorType& allocator);
98
99
    Status get_segment_num_rows(std::vector<uint32_t>* segment_rows, bool enable_segment_cache,
100
                                OlapReaderStatistics* read_stats,
101
                                const io::IOContext* io_ctx = nullptr);
102
103
protected:
104
    BetaRowset(const TabletSchemaSPtr& schema, const RowsetMetaSharedPtr& rowset_meta,
105
               std::string tablet_path);
106
107
    // init segment groups
108
    Status init() override;
109
110
    void do_close() override;
111
112
    Status check_current_rowset_segment() override;
113
114
    void clear_inverted_index_cache() override;
115
116
private:
117
    friend class RowsetFactory;
118
    friend class BetaRowsetReader;
119
120
    std::mutex _segment_rows_mutex;
121
    std::atomic<bool> _segment_rows_loaded {false};
122
    std::vector<uint32_t> _segments_rows;
123
};
124
125
} // namespace doris
126
127
#endif //DORIS_SRC_OLAP_ROWSET_BETA_ROWSET_H_