Coverage Report

Created: 2026-06-03 09:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/rowset/rowset_meta.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_BE_SRC_OLAP_ROWSET_ROWSET_META_H
19
#define DORIS_BE_SRC_OLAP_ROWSET_ROWSET_META_H
20
21
#include <gen_cpp/olap_file.pb.h>
22
#include <glog/logging.h>
23
24
#include <atomic>
25
#include <chrono>
26
#include <cstdint>
27
#include <memory>
28
#include <string>
29
#include <vector>
30
31
#include "common/cast_set.h"
32
#include "common/config.h"
33
#include "common/status.h"
34
#include "io/fs/encrypted_fs_factory.h"
35
#include "io/fs/file_system.h"
36
#include "runtime/memory/lru_cache_policy.h"
37
#include "storage/compaction/binlog_compaction_policy.h"
38
#include "storage/metadata_adder.h"
39
#include "storage/olap_common.h"
40
#include "storage/rowset/rowset_fwd.h"
41
#include "storage/storage_policy.h"
42
#include "storage/tablet/tablet_fwd.h"
43
#include "util/once.h"
44
45
namespace doris {
46
47
class RowsetMeta : public MetadataAdder<RowsetMeta> {
48
public:
49
931k
    RowsetMeta() = default;
50
    ~RowsetMeta();
51
52
    bool init(std::string_view pb_rowset_meta);
53
54
    bool init(const RowsetMeta* rowset_meta);
55
56
    bool init_from_pb(const RowsetMetaPB& rowset_meta_pb);
57
58
    bool init_from_json(const std::string& json_rowset_meta);
59
60
6
    bool serialize(std::string* value) { return _serialize_to_pb(value); }
61
62
    bool json_rowset_meta(std::string* json_rowset_meta);
63
64
    // If the rowset is a local rowset, return the global local file system.
65
    // Otherwise, return the remote file system corresponding to rowset's resource id.
66
    // Note that if the resource id cannot be found for the corresponding remote file system, nullptr will be returned.
67
    MOCK_FUNCTION io::FileSystemSPtr fs();
68
69
    io::FileSystemSPtr physical_fs();
70
71
    Result<const StorageResource*> remote_storage_resource();
72
73
    void set_remote_storage_resource(StorageResource resource);
74
75
33.8k
    const std::string& resource_id() const { return _rowset_meta_pb.resource_id(); }
76
77
1.83k
    void set_resource_id(const std::string& resource_id) {
78
1.83k
        _rowset_meta_pb.set_resource_id(resource_id);
79
1.83k
    }
80
81
29.6M
    bool is_local() const { return !_rowset_meta_pb.has_resource_id(); }
82
83
    bool has_variant_type_in_schema() const;
84
85
43.7M
    RowsetId rowset_id() const { return _rowset_id; }
86
87
250k
    void set_rowset_id(const RowsetId& rowset_id) {
88
        // rowset id is a required field, just set it to 0
89
250k
        _rowset_meta_pb.set_rowset_id(0);
90
250k
        _rowset_id = rowset_id;
91
250k
        _rowset_meta_pb.set_rowset_id_v2(rowset_id.to_string());
92
250k
    }
93
94
13.7M
    int64_t tablet_id() const { return _rowset_meta_pb.tablet_id(); }
95
96
251k
    void set_tablet_id(int64_t tablet_id) { _rowset_meta_pb.set_tablet_id(tablet_id); }
97
98
924
    int64_t db_id() const { return _rowset_meta_pb.db_id(); }
99
100
244k
    void set_db_id(int64_t db_id) { _rowset_meta_pb.set_db_id(db_id); }
101
102
924
    int64_t table_id() const { return _rowset_meta_pb.table_id(); }
103
104
244k
    void set_table_id(int64_t table_id) { _rowset_meta_pb.set_table_id(table_id); }
105
106
    int64_t index_id() const { return _rowset_meta_pb.index_id(); }
107
108
245k
    void set_index_id(int64_t index_id) { _rowset_meta_pb.set_index_id(index_id); }
109
110
157k
    TabletUid tablet_uid() const { return _rowset_meta_pb.tablet_uid(); }
111
112
56.5k
    void set_tablet_uid(TabletUid tablet_uid) {
113
56.5k
        *(_rowset_meta_pb.mutable_tablet_uid()) = tablet_uid.to_proto();
114
56.5k
    }
115
116
1.70M
    int64_t txn_id() const { return _rowset_meta_pb.txn_id(); }
117
118
231k
    void set_txn_id(int64_t txn_id) { _rowset_meta_pb.set_txn_id(txn_id); }
119
120
2.37k
    int32_t tablet_schema_hash() const { return _rowset_meta_pb.tablet_schema_hash(); }
121
122
245k
    void set_tablet_schema_hash(int32_t tablet_schema_hash) {
123
245k
        _rowset_meta_pb.set_tablet_schema_hash(tablet_schema_hash);
124
245k
    }
125
126
15
    void mark_row_binlog() { _rowset_meta_pb.set_is_row_binlog(true); }
127
128
2.89M
    bool is_row_binlog() const {
129
2.89M
        return _rowset_meta_pb.has_is_row_binlog() && _rowset_meta_pb.is_row_binlog();
130
2.89M
    }
131
132
1.42M
    RowsetTypePB rowset_type() const { return _rowset_meta_pb.rowset_type(); }
133
134
247k
    void set_rowset_type(RowsetTypePB rowset_type) { _rowset_meta_pb.set_rowset_type(rowset_type); }
135
136
527k
    RowsetStatePB rowset_state() const { return _rowset_meta_pb.rowset_state(); }
137
138
531k
    void set_rowset_state(RowsetStatePB rowset_state) {
139
531k
        _rowset_meta_pb.set_rowset_state(rowset_state);
140
531k
    }
141
142
58.5M
    Version version() const {
143
58.5M
        return {_rowset_meta_pb.start_version(), _rowset_meta_pb.end_version()};
144
58.5M
    }
145
146
297k
    void set_version(Version version) {
147
297k
        _rowset_meta_pb.set_start_version(version.first);
148
297k
        _rowset_meta_pb.set_end_version(version.second);
149
297k
    }
150
151
718k
    bool has_version() const {
152
718k
        return _rowset_meta_pb.has_start_version() && _rowset_meta_pb.has_end_version();
153
718k
    }
154
155
5.85M
    int64_t start_version() const { return _rowset_meta_pb.start_version(); }
156
157
7.82M
    int64_t end_version() const { return _rowset_meta_pb.end_version(); }
158
159
12.1M
    int64_t num_rows() const { return _rowset_meta_pb.num_rows(); }
160
161
282k
    void set_num_rows(int64_t num_rows) { _rowset_meta_pb.set_num_rows(num_rows); }
162
163
276k
    void set_num_segment_rows(const std::vector<uint32_t>& num_segment_rows) {
164
276k
        _rowset_meta_pb.mutable_num_segment_rows()->Assign(num_segment_rows.cbegin(),
165
276k
                                                           num_segment_rows.cend());
166
276k
    }
167
168
4.16k
    void get_num_segment_rows(std::vector<uint32_t>* num_segment_rows) const {
169
4.16k
        num_segment_rows->assign(_rowset_meta_pb.num_segment_rows().cbegin(),
170
4.16k
                                 _rowset_meta_pb.num_segment_rows().cend());
171
4.16k
    }
172
173
199k
    auto& get_num_segment_rows() const { return _rowset_meta_pb.num_segment_rows(); }
174
175
7.57M
    int64_t total_disk_size() const { return _rowset_meta_pb.total_disk_size(); }
176
177
293k
    void set_total_disk_size(int64_t total_disk_size) {
178
293k
        _rowset_meta_pb.set_total_disk_size(total_disk_size);
179
293k
    }
180
181
4.09M
    int64_t data_disk_size() const { return _rowset_meta_pb.data_disk_size(); }
182
183
282k
    void set_data_disk_size(int64_t data_disk_size) {
184
282k
        _rowset_meta_pb.set_data_disk_size(data_disk_size);
185
282k
    }
186
187
1.26M
    int64_t index_disk_size() const { return _rowset_meta_pb.index_disk_size(); }
188
189
282k
    void set_index_disk_size(int64_t index_disk_size) {
190
282k
        _rowset_meta_pb.set_index_disk_size(index_disk_size);
191
282k
    }
192
193
0
    void zone_maps(std::vector<ZoneMap>* zone_maps) {
194
0
        for (const ZoneMap& zone_map : _rowset_meta_pb.zone_maps()) {
195
0
            zone_maps->push_back(zone_map);
196
0
        }
197
0
    }
198
199
0
    void set_zone_maps(const std::vector<ZoneMap>& zone_maps) {
200
0
        for (const ZoneMap& zone_map : zone_maps) {
201
0
            ZoneMap* new_zone_map = _rowset_meta_pb.add_zone_maps();
202
0
            *new_zone_map = zone_map;
203
0
        }
204
0
    }
205
206
0
    void add_zone_map(const ZoneMap& zone_map) {
207
0
        ZoneMap* new_zone_map = _rowset_meta_pb.add_zone_maps();
208
0
        *new_zone_map = zone_map;
209
0
    }
210
211
7.64M
    bool has_delete_predicate() const { return _rowset_meta_pb.has_delete_predicate(); }
212
213
8.31k
    const DeletePredicatePB& delete_predicate() const { return _rowset_meta_pb.delete_predicate(); }
214
215
22
    DeletePredicatePB* mutable_delete_predicate() {
216
22
        return _rowset_meta_pb.mutable_delete_predicate();
217
22
    }
218
219
3.30k
    void set_delete_predicate(DeletePredicatePB delete_predicate) {
220
3.30k
        DeletePredicatePB* new_delete_condition = _rowset_meta_pb.mutable_delete_predicate();
221
3.30k
        *new_delete_condition = std::move(delete_predicate);
222
3.30k
    }
223
224
9.71k
    bool empty() const { return _rowset_meta_pb.empty(); }
225
226
278k
    void set_empty(bool empty) { _rowset_meta_pb.set_empty(empty); }
227
228
58
    PUniqueId load_id() const { return _rowset_meta_pb.load_id(); }
229
230
214k
    void set_load_id(PUniqueId load_id) {
231
214k
        PUniqueId* new_load_id = _rowset_meta_pb.mutable_load_id();
232
214k
        new_load_id->set_hi(load_id.hi());
233
214k
        new_load_id->set_lo(load_id.lo());
234
214k
    }
235
236
196k
    void set_job_id(const std::string& job_id) { _rowset_meta_pb.set_job_id(job_id); }
237
238
0
    const std::string& job_id() const { return _rowset_meta_pb.job_id(); }
239
240
0
    bool delete_flag() const { return _rowset_meta_pb.delete_flag(); }
241
242
138k
    int64_t creation_time() const { return _rowset_meta_pb.creation_time(); }
243
244
314k
    void set_creation_time(int64_t creation_time) {
245
314k
        return _rowset_meta_pb.set_creation_time(creation_time);
246
314k
    }
247
248
531k
    int64_t stale_at() const {
249
531k
        int64_t stale_time = _stale_at_s.load();
250
531k
        return stale_time > 0 ? stale_time : _rowset_meta_pb.creation_time();
251
531k
    }
252
253
12.6k
    bool has_stale_at() const { return _stale_at_s.load() > 0; }
254
255
98.3k
    void set_stale_at(int64_t stale_at) { _stale_at_s.store(stale_at); }
256
257
44.0k
    int64_t partition_id() const { return _rowset_meta_pb.partition_id(); }
258
259
246k
    void set_partition_id(int64_t partition_id) {
260
246k
        return _rowset_meta_pb.set_partition_id(partition_id);
261
246k
    }
262
263
31.9M
    int64_t num_segments() const { return _rowset_meta_pb.num_segments(); }
264
265
286k
    void set_num_segments(int64_t num_segments) { _rowset_meta_pb.set_num_segments(num_segments); }
266
267
    // Convert to RowsetMetaPB, skip_schema is only used by cloud to separate schema from rowset meta.
268
    void to_rowset_pb(RowsetMetaPB* rs_meta_pb, bool skip_schema = false) const;
269
270
    // Convert to RowsetMetaPB, skip_schema is only used by cloud to separate schema from rowset meta.
271
    RowsetMetaPB get_rowset_pb(bool skip_schema = false) const;
272
273
292
    inline DeletePredicatePB* mutable_delete_pred_pb() {
274
292
        return _rowset_meta_pb.mutable_delete_predicate();
275
292
    }
276
277
2.83k
    bool is_singleton_delta() const {
278
2.83k
        return has_version() && _rowset_meta_pb.start_version() == _rowset_meta_pb.end_version();
279
2.83k
    }
280
281
    // Some time, we may check if this rowset is in rowset meta manager's meta by using RowsetMetaManager::check_rowset_meta.
282
    // But, this check behavior may cost a lot of time when it is frequent.
283
    // If we explicitly remove this rowset from rowset meta manager's meta, we can set _is_removed_from_rowset_meta to true,
284
    // And next time when we want to check if this rowset is in rowset mata manager's meta, we can
285
    // check is_remove_from_rowset_meta() first.
286
64.3k
    void set_remove_from_rowset_meta() { _is_removed_from_rowset_meta = true; }
287
288
66.2k
    bool is_remove_from_rowset_meta() const { return _is_removed_from_rowset_meta; }
289
290
37.2k
    SegmentsOverlapPB segments_overlap() const { return _rowset_meta_pb.segments_overlap_pb(); }
291
292
357k
    void set_segments_overlap(SegmentsOverlapPB segments_overlap) {
293
357k
        _rowset_meta_pb.set_segments_overlap_pb(segments_overlap);
294
357k
    }
295
296
762k
    static bool comparator(const RowsetMetaSharedPtr& left, const RowsetMetaSharedPtr& right) {
297
762k
        return left->end_version() < right->end_version();
298
762k
    }
299
300
    // return true if segments in this rowset has overlapping data.
301
    // this is not same as `segments_overlap()` method.
302
    // `segments_overlap()` only return the value of "segments_overlap" field in rowset meta,
303
    // but "segments_overlap" may be UNKNOWN.
304
    //
305
    // Returns true if all of the following conditions are met
306
    // 1. the rowset contains more than one segment
307
    // 2. the rowset's start version == end version (non-singleton rowset was generated by compaction process
308
    //    which always produces non-overlapped segments)
309
    // 3. segments_overlap() flag is not NONOVERLAPPING (OVERLAP_UNKNOWN and OVERLAPPING are OK)
310
6.40M
    bool is_segments_overlapping() const {
311
6.40M
        return num_segments() > 1 && is_singleton_delta() && segments_overlap() != NONOVERLAPPING;
312
6.40M
    }
313
314
47
    bool produced_by_compaction() const {
315
47
        return has_version() &&
316
47
               (start_version() < end_version() ||
317
47
                (start_version() == end_version() && segments_overlap() == NONOVERLAPPING));
318
47
    }
319
320
    // get the compaction score of this rowset.
321
    // if segments are overlapping, the score equals to the number of segments,
322
    // otherwise, score is 1.
323
2.70M
    uint32_t get_compaction_score() const {
324
        // Row binlog LMax Base([0-x]) only performs meta-only merge, so treat it as score 1.
325
2.70M
        if (is_row_binlog() &&
326
2.70M
            _rowset_meta_pb.compaction_level() ==
327
3.04k
                    BinlogCompactionPolicy::kBinlogCompactionMaxLevel - 1 &&
328
2.70M
            start_version() == 0) {
329
0
            return 1;
330
0
        }
331
332
2.70M
        uint32_t score = 0;
333
2.70M
        if (!is_segments_overlapping()) {
334
2.70M
            score = 1;
335
2.70M
        } else {
336
418
            auto num_seg = num_segments();
337
418
            DCHECK_GT(num_seg, 0);
338
418
            score = cast_set<uint32_t>(num_seg);
339
418
            CHECK(score > 0);
340
418
        }
341
2.70M
        return score;
342
2.70M
    }
343
344
82.9k
    uint32_t get_merge_way_num() const {
345
82.9k
        uint32_t way_num = 0;
346
83.0k
        if (!is_segments_overlapping()) {
347
83.0k
            if (num_segments() == 0) {
348
44.4k
                way_num = 0;
349
44.4k
            } else {
350
38.5k
                way_num = 1;
351
38.5k
            }
352
18.4E
        } else {
353
18.4E
            auto num_seg = num_segments();
354
18.4E
            DCHECK_GT(num_seg, 0);
355
356
18.4E
            way_num = cast_set<uint32_t>(num_seg);
357
18.4E
            CHECK(way_num > 0);
358
18.4E
        }
359
82.9k
        return way_num;
360
82.9k
    }
361
362
4.31M
    void get_segments_key_bounds(std::vector<KeyBoundsPB>* segments_key_bounds) const {
363
4.31M
        for (const KeyBoundsPB& key_range : _rowset_meta_pb.segments_key_bounds()) {
364
4.10M
            segments_key_bounds->push_back(key_range);
365
4.10M
        }
366
4.31M
    }
367
368
3.75k
    auto& get_segments_key_bounds() const { return _rowset_meta_pb.segments_key_bounds(); }
369
370
5.89M
    bool is_segments_key_bounds_truncated() const {
371
5.89M
        return _rowset_meta_pb.has_segments_key_bounds_truncated() &&
372
5.89M
               _rowset_meta_pb.segments_key_bounds_truncated();
373
5.89M
    }
374
375
337k
    void set_segments_key_bounds_truncated(bool truncated) {
376
337k
        _rowset_meta_pb.set_segments_key_bounds_truncated(truncated);
377
337k
    }
378
379
    // When true, `segments_key_bounds` holds a single aggregated
380
    // [rowset_min, rowset_max] entry instead of per-segment bounds.
381
4.31M
    bool is_segments_key_bounds_aggregated() const {
382
4.31M
        return _rowset_meta_pb.has_segments_key_bounds_aggregated() &&
383
4.31M
               _rowset_meta_pb.segments_key_bounds_aggregated();
384
4.31M
    }
385
386
277k
    void set_segments_key_bounds_aggregated(bool aggregated) {
387
277k
        _rowset_meta_pb.set_segments_key_bounds_aggregated(aggregated);
388
277k
    }
389
390
1.53M
    bool get_first_segment_key_bound(KeyBoundsPB* key_bounds) {
391
        // for compatibility, old version has not segment key bounds
392
1.53M
        if (_rowset_meta_pb.segments_key_bounds_size() == 0) {
393
0
            return false;
394
0
        }
395
1.53M
        *key_bounds = *_rowset_meta_pb.segments_key_bounds().begin();
396
1.53M
        return true;
397
1.53M
    }
398
399
1.03M
    bool get_last_segment_key_bound(KeyBoundsPB* key_bounds) {
400
1.03M
        if (_rowset_meta_pb.segments_key_bounds_size() == 0) {
401
0
            return false;
402
0
        }
403
1.03M
        *key_bounds = *_rowset_meta_pb.segments_key_bounds().rbegin();
404
1.03M
        return true;
405
1.03M
    }
406
407
    // If `aggregate_into_single` is true, collapse per-segment bounds into a single
408
    // [rowset_min, rowset_max] entry and mark this rowset as aggregated.
409
    void set_segments_key_bounds(const std::vector<KeyBoundsPB>& segments_key_bounds,
410
                                 bool aggregate_into_single = false);
411
412
19
    void add_segment_key_bounds(KeyBoundsPB segments_key_bounds) {
413
19
        *_rowset_meta_pb.add_segments_key_bounds() = std::move(segments_key_bounds);
414
19
        set_segments_overlap(OVERLAPPING);
415
19
    }
416
417
248k
    void set_newest_write_timestamp(int64_t timestamp) {
418
248k
        _rowset_meta_pb.set_newest_write_timestamp(timestamp);
419
248k
    }
420
421
581k
    int64_t newest_write_timestamp() const { return _rowset_meta_pb.newest_write_timestamp(); }
422
423
    // for cloud only
424
395
    bool has_visible_ts_ms() const { return _rowset_meta_pb.has_visible_ts_ms(); }
425
388
    int64_t visible_ts_ms() const { return _rowset_meta_pb.visible_ts_ms(); }
426
395
    std::chrono::time_point<std::chrono::system_clock> visible_timestamp() const {
427
395
        using namespace std::chrono;
428
395
        if (has_visible_ts_ms()) {
429
388
            return time_point<system_clock>(milliseconds(visible_ts_ms()));
430
388
        }
431
7
        return system_clock::from_time_t(newest_write_timestamp());
432
395
    }
433
172k
    void set_visible_ts_ms(int64_t visible_ts_ms) {
434
172k
        _rowset_meta_pb.set_visible_ts_ms(visible_ts_ms);
435
172k
    }
436
437
    void set_tablet_schema(const TabletSchemaSPtr& tablet_schema);
438
    void set_tablet_schema(const TabletSchemaPB& tablet_schema);
439
440
4.90M
    const TabletSchemaSPtr& tablet_schema() const { return _schema; }
441
442
192k
    void set_txn_expiration(int64_t expiration) { _rowset_meta_pb.set_txn_expiration(expiration); }
443
444
243k
    void set_compaction_level(int64_t compaction_level) {
445
243k
        _rowset_meta_pb.set_compaction_level(compaction_level);
446
243k
    }
447
448
8.49k
    int64_t compaction_level() { return _rowset_meta_pb.compaction_level(); }
449
450
    // `seg_file_size` MUST ordered by segment id
451
    void add_segments_file_size(const std::vector<size_t>& seg_file_size);
452
453
    // Return -1 if segment file size is unknown
454
    int64_t segment_file_size(int seg_id) const;
455
456
3.33k
    const auto& segments_file_size() const { return _rowset_meta_pb.segments_file_size(); }
457
458
    // Used for partial update, when publish, partial update may add a new rowset and we should update rowset meta
459
    void merge_rowset_meta(const RowsetMeta& other);
460
461
    InvertedIndexFileInfo inverted_index_file_info(int seg_id);
462
463
192
    const auto& inverted_index_file_info() const {
464
192
        return _rowset_meta_pb.inverted_index_file_info();
465
192
    }
466
467
    void add_inverted_index_files_info(
468
            const std::vector<const InvertedIndexFileInfo*>& idx_file_info);
469
470
    int64_t get_metadata_size() const override;
471
472
    // Because the member field '_handle' is a raw pointer, use member func 'init' to replace copy ctor
473
    RowsetMeta(const RowsetMeta&) = delete;
474
    RowsetMeta operator=(const RowsetMeta&) = delete;
475
476
    void add_packed_slice_location(const std::string& segment_path,
477
                                   const std::string& packed_file_path, int64_t offset,
478
142k
                                   int64_t size, int64_t packed_file_size) {
479
142k
        auto* index_map = _rowset_meta_pb.mutable_packed_slice_locations();
480
142k
        auto& index_pb = (*index_map)[segment_path];
481
142k
        index_pb.set_packed_file_path(packed_file_path);
482
142k
        index_pb.set_offset(offset);
483
142k
        index_pb.set_size(size);
484
142k
        index_pb.set_packed_file_size(packed_file_size);
485
142k
    }
486
487
31.5k
    int32_t schema_version() const { return _rowset_meta_pb.schema_version(); }
488
489
0
    std::string debug_string() const { return _rowset_meta_pb.ShortDebugString(); }
490
491
    // Pre-set the encryption algorithm to avoid re-entrant get_tablet calls
492
    // that can cause SingleFlight deadlock during tablet loading.
493
171k
    void set_encryption_algorithm(EncryptionAlgorithmPB algorithm) {
494
171k
        _determine_encryption_once.call(
495
171k
                [algorithm]() -> Result<EncryptionAlgorithmPB> { return algorithm; });
496
171k
    }
497
498
4.25M
    TsoRange commit_tso() const {
499
4.25M
        const auto& commit_tso_pb = _rowset_meta_pb.commit_tso();
500
4.25M
        return {commit_tso_pb.start_tso(), commit_tso_pb.end_tso()};
501
4.25M
    }
502
503
518
    bool has_commit_tso() const { return _rowset_meta_pb.has_commit_tso(); }
504
505
47.5k
    void set_commit_tso(const TsoRange& commit_tso) {
506
47.5k
        auto* commit_tso_pb = _rowset_meta_pb.mutable_commit_tso();
507
47.5k
        commit_tso_pb->set_start_tso(commit_tso.start_tso());
508
47.5k
        commit_tso_pb->set_end_tso(commit_tso.end_tso());
509
47.5k
    }
510
511
36.4k
    void set_commit_tso(int64_t commit_tso) { set_commit_tso({commit_tso, commit_tso}); }
512
513
171k
    void set_cloud_fields_after_visible(int64_t visible_version, int64_t version_update_time_ms) {
514
        // Update rowset meta with correct version and visible_ts
515
        // !!ATTENTION!!: this code should be updated if there are more fields
516
        // in rowset meta which will be modified in meta-service when commit_txn in the future
517
171k
        set_version({visible_version, visible_version});
518
171k
        if (version_update_time_ms > 0) {
519
171k
            set_visible_ts_ms(version_update_time_ms);
520
171k
        }
521
171k
    }
522
523
private:
524
    bool _deserialize_from_pb(std::string_view value);
525
526
    bool _serialize_to_pb(std::string* value);
527
528
    void _init();
529
530
    friend bool operator==(const RowsetMeta& a, const RowsetMeta& b);
531
532
0
    friend bool operator!=(const RowsetMeta& a, const RowsetMeta& b) { return !(a == b); }
533
534
private:
535
    RowsetMetaPB _rowset_meta_pb;
536
    TabletSchemaSPtr _schema;
537
    Cache::Handle* _handle = nullptr;
538
    RowsetId _rowset_id;
539
    StorageResource _storage_resource;
540
    bool _is_removed_from_rowset_meta = false;
541
    DorisCallOnce<Result<EncryptionAlgorithmPB>> _determine_encryption_once;
542
    std::atomic<int64_t> _stale_at_s {0};
543
};
544
545
using RowsetMetaMapContainer = std::unordered_map<Version, RowsetMetaSharedPtr, HashOfVersion>;
546
547
} // namespace doris
548
549
#endif // DORIS_BE_SRC_OLAP_ROWSET_ROWSET_META_H