Coverage Report

Created: 2026-08-26 14:46

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