Coverage Report

Created: 2026-06-03 21:35

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
17.0k
    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
36
    const std::string& resource_id() const { return _rowset_meta_pb.resource_id(); }
76
77
22
    void set_resource_id(const std::string& resource_id) {
78
22
        _rowset_meta_pb.set_resource_id(resource_id);
79
22
    }
80
81
20.2k
    bool is_local() const { return !_rowset_meta_pb.has_resource_id(); }
82
83
    bool has_variant_type_in_schema() const;
84
85
2.53M
    RowsetId rowset_id() const { return _rowset_id; }
86
87
7.21k
    void set_rowset_id(const RowsetId& rowset_id) {
88
        // rowset id is a required field, just set it to 0
89
7.21k
        _rowset_meta_pb.set_rowset_id(0);
90
7.21k
        _rowset_id = rowset_id;
91
7.21k
        _rowset_meta_pb.set_rowset_id_v2(rowset_id.to_string());
92
7.21k
    }
93
94
8.31k
    int64_t tablet_id() const { return _rowset_meta_pb.tablet_id(); }
95
96
6.22k
    void set_tablet_id(int64_t tablet_id) { _rowset_meta_pb.set_tablet_id(tablet_id); }
97
98
24
    int64_t db_id() const { return _rowset_meta_pb.db_id(); }
99
100
918
    void set_db_id(int64_t db_id) { _rowset_meta_pb.set_db_id(db_id); }
101
102
24
    int64_t table_id() const { return _rowset_meta_pb.table_id(); }
103
104
918
    void set_table_id(int64_t table_id) { _rowset_meta_pb.set_table_id(table_id); }
105
106
1
    int64_t index_id() const { return _rowset_meta_pb.index_id(); }
107
108
936
    void set_index_id(int64_t index_id) { _rowset_meta_pb.set_index_id(index_id); }
109
110
22
    TabletUid tablet_uid() const { return _rowset_meta_pb.tablet_uid(); }
111
112
6.13k
    void set_tablet_uid(TabletUid tablet_uid) {
113
6.13k
        *(_rowset_meta_pb.mutable_tablet_uid()) = tablet_uid.to_proto();
114
6.13k
    }
115
116
22
    int64_t txn_id() const { return _rowset_meta_pb.txn_id(); }
117
118
145
    void set_txn_id(int64_t txn_id) { _rowset_meta_pb.set_txn_id(txn_id); }
119
120
35
    int32_t tablet_schema_hash() const { return _rowset_meta_pb.tablet_schema_hash(); }
121
122
1.00k
    void set_tablet_schema_hash(int32_t tablet_schema_hash) {
123
1.00k
        _rowset_meta_pb.set_tablet_schema_hash(tablet_schema_hash);
124
1.00k
    }
125
126
9
    void mark_row_binlog() { _rowset_meta_pb.set_is_row_binlog(true); }
127
128
19.9k
    bool is_row_binlog() const {
129
19.9k
        return _rowset_meta_pb.has_is_row_binlog() && _rowset_meta_pb.is_row_binlog();
130
19.9k
    }
131
132
12.3k
    RowsetTypePB rowset_type() const { return _rowset_meta_pb.rowset_type(); }
133
134
2.83k
    void set_rowset_type(RowsetTypePB rowset_type) { _rowset_meta_pb.set_rowset_type(rowset_type); }
135
136
10.7k
    RowsetStatePB rowset_state() const { return _rowset_meta_pb.rowset_state(); }
137
138
1.94k
    void set_rowset_state(RowsetStatePB rowset_state) {
139
1.94k
        _rowset_meta_pb.set_rowset_state(rowset_state);
140
1.94k
    }
141
142
2.20M
    Version version() const {
143
2.20M
        return {_rowset_meta_pb.start_version(), _rowset_meta_pb.end_version()};
144
2.20M
    }
145
146
7.00k
    void set_version(Version version) {
147
7.00k
        _rowset_meta_pb.set_start_version(version.first);
148
7.00k
        _rowset_meta_pb.set_end_version(version.second);
149
7.00k
    }
150
151
12.4k
    bool has_version() const {
152
12.4k
        return _rowset_meta_pb.has_start_version() && _rowset_meta_pb.has_end_version();
153
12.4k
    }
154
155
20.7k
    int64_t start_version() const { return _rowset_meta_pb.start_version(); }
156
157
29.3k
    int64_t end_version() const { return _rowset_meta_pb.end_version(); }
158
159
1.41k
    int64_t num_rows() const { return _rowset_meta_pb.num_rows(); }
160
161
1.41k
    void set_num_rows(int64_t num_rows) { _rowset_meta_pb.set_num_rows(num_rows); }
162
163
979
    void set_num_segment_rows(const std::vector<uint32_t>& num_segment_rows) {
164
979
        _rowset_meta_pb.mutable_num_segment_rows()->Assign(num_segment_rows.cbegin(),
165
979
                                                           num_segment_rows.cend());
166
979
    }
167
168
87
    void get_num_segment_rows(std::vector<uint32_t>* num_segment_rows) const {
169
87
        num_segment_rows->assign(_rowset_meta_pb.num_segment_rows().cbegin(),
170
87
                                 _rowset_meta_pb.num_segment_rows().cend());
171
87
    }
172
173
1.60k
    auto& get_num_segment_rows() const { return _rowset_meta_pb.num_segment_rows(); }
174
175
6.68k
    int64_t total_disk_size() const { return _rowset_meta_pb.total_disk_size(); }
176
177
8.23k
    void set_total_disk_size(int64_t total_disk_size) {
178
8.23k
        _rowset_meta_pb.set_total_disk_size(total_disk_size);
179
8.23k
    }
180
181
251
    int64_t data_disk_size() const { return _rowset_meta_pb.data_disk_size(); }
182
183
1.10k
    void set_data_disk_size(int64_t data_disk_size) {
184
1.10k
        _rowset_meta_pb.set_data_disk_size(data_disk_size);
185
1.10k
    }
186
187
242
    int64_t index_disk_size() const { return _rowset_meta_pb.index_disk_size(); }
188
189
1.10k
    void set_index_disk_size(int64_t index_disk_size) {
190
1.10k
        _rowset_meta_pb.set_index_disk_size(index_disk_size);
191
1.10k
    }
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
5.90k
    bool has_delete_predicate() const { return _rowset_meta_pb.has_delete_predicate(); }
212
213
171
    const DeletePredicatePB& delete_predicate() const { return _rowset_meta_pb.delete_predicate(); }
214
215
0
    DeletePredicatePB* mutable_delete_predicate() {
216
0
        return _rowset_meta_pb.mutable_delete_predicate();
217
0
    }
218
219
83
    void set_delete_predicate(DeletePredicatePB delete_predicate) {
220
83
        DeletePredicatePB* new_delete_condition = _rowset_meta_pb.mutable_delete_predicate();
221
83
        *new_delete_condition = std::move(delete_predicate);
222
83
    }
223
224
54
    bool empty() const { return _rowset_meta_pb.empty(); }
225
226
1.10k
    void set_empty(bool empty) { _rowset_meta_pb.set_empty(empty); }
227
228
0
    PUniqueId load_id() const { return _rowset_meta_pb.load_id(); }
229
230
52
    void set_load_id(PUniqueId load_id) {
231
52
        PUniqueId* new_load_id = _rowset_meta_pb.mutable_load_id();
232
52
        new_load_id->set_hi(load_id.hi());
233
52
        new_load_id->set_lo(load_id.lo());
234
52
    }
235
236
1
    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
30
    int64_t creation_time() const { return _rowset_meta_pb.creation_time(); }
243
244
1.08k
    void set_creation_time(int64_t creation_time) {
245
1.08k
        return _rowset_meta_pb.set_creation_time(creation_time);
246
1.08k
    }
247
248
717
    int64_t stale_at() const {
249
717
        int64_t stale_time = _stale_at_s.load();
250
717
        return stale_time > 0 ? stale_time : _rowset_meta_pb.creation_time();
251
717
    }
252
253
2
    bool has_stale_at() const { return _stale_at_s.load() > 0; }
254
255
632
    void set_stale_at(int64_t stale_at) { _stale_at_s.store(stale_at); }
256
257
11
    int64_t partition_id() const { return _rowset_meta_pb.partition_id(); }
258
259
937
    void set_partition_id(int64_t partition_id) {
260
937
        return _rowset_meta_pb.set_partition_id(partition_id);
261
937
    }
262
263
50.9k
    int64_t num_segments() const { return _rowset_meta_pb.num_segments(); }
264
265
5.06k
    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
0
    inline DeletePredicatePB* mutable_delete_pred_pb() {
274
0
        return _rowset_meta_pb.mutable_delete_predicate();
275
0
    }
276
277
937
    bool is_singleton_delta() const {
278
937
        return has_version() && _rowset_meta_pb.start_version() == _rowset_meta_pb.end_version();
279
937
    }
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
0
    void set_remove_from_rowset_meta() { _is_removed_from_rowset_meta = true; }
287
288
0
    bool is_remove_from_rowset_meta() const { return _is_removed_from_rowset_meta; }
289
290
1.53k
    SegmentsOverlapPB segments_overlap() const { return _rowset_meta_pb.segments_overlap_pb(); }
291
292
5.44k
    void set_segments_overlap(SegmentsOverlapPB segments_overlap) {
293
5.44k
        _rowset_meta_pb.set_segments_overlap_pb(segments_overlap);
294
5.44k
    }
295
296
7.52k
    static bool comparator(const RowsetMetaSharedPtr& left, const RowsetMetaSharedPtr& right) {
297
7.52k
        return left->end_version() < right->end_version();
298
7.52k
    }
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
18.5k
    bool is_segments_overlapping() const {
311
18.5k
        return num_segments() > 1 && is_singleton_delta() && segments_overlap() != NONOVERLAPPING;
312
18.5k
    }
313
314
0
    bool produced_by_compaction() const {
315
0
        return has_version() &&
316
0
               (start_version() < end_version() ||
317
0
                (start_version() == end_version() && segments_overlap() == NONOVERLAPPING));
318
0
    }
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
16.7k
    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
16.7k
        if (is_row_binlog() &&
326
16.7k
            _rowset_meta_pb.compaction_level() ==
327
0
                    BinlogCompactionPolicy::kBinlogCompactionMaxLevel - 1 &&
328
16.7k
            start_version() == 0) {
329
0
            return 1;
330
0
        }
331
332
16.7k
        uint32_t score = 0;
333
16.7k
        if (!is_segments_overlapping()) {
334
16.6k
            score = 1;
335
16.6k
        } else {
336
96
            auto num_seg = num_segments();
337
96
            DCHECK_GT(num_seg, 0);
338
96
            score = cast_set<uint32_t>(num_seg);
339
96
            CHECK(score > 0);
340
96
        }
341
16.7k
        return score;
342
16.7k
    }
343
344
0
    uint32_t get_merge_way_num() const {
345
0
        uint32_t way_num = 0;
346
0
        if (!is_segments_overlapping()) {
347
0
            if (num_segments() == 0) {
348
0
                way_num = 0;
349
0
            } else {
350
0
                way_num = 1;
351
0
            }
352
0
        } else {
353
0
            auto num_seg = num_segments();
354
0
            DCHECK_GT(num_seg, 0);
355
356
0
            way_num = cast_set<uint32_t>(num_seg);
357
0
            CHECK(way_num > 0);
358
0
        }
359
0
        return way_num;
360
0
    }
361
362
212
    void get_segments_key_bounds(std::vector<KeyBoundsPB>* segments_key_bounds) const {
363
228
        for (const KeyBoundsPB& key_range : _rowset_meta_pb.segments_key_bounds()) {
364
228
            segments_key_bounds->push_back(key_range);
365
228
        }
366
212
    }
367
368
3
    auto& get_segments_key_bounds() const { return _rowset_meta_pb.segments_key_bounds(); }
369
370
1.43k
    bool is_segments_key_bounds_truncated() const {
371
1.43k
        return _rowset_meta_pb.has_segments_key_bounds_truncated() &&
372
1.43k
               _rowset_meta_pb.segments_key_bounds_truncated();
373
1.43k
    }
374
375
1.43k
    void set_segments_key_bounds_truncated(bool truncated) {
376
1.43k
        _rowset_meta_pb.set_segments_key_bounds_truncated(truncated);
377
1.43k
    }
378
379
    // When true, `segments_key_bounds` holds a single aggregated
380
    // [rowset_min, rowset_max] entry instead of per-segment bounds.
381
87
    bool is_segments_key_bounds_aggregated() const {
382
87
        return _rowset_meta_pb.has_segments_key_bounds_aggregated() &&
383
87
               _rowset_meta_pb.segments_key_bounds_aggregated();
384
87
    }
385
386
982
    void set_segments_key_bounds_aggregated(bool aggregated) {
387
982
        _rowset_meta_pb.set_segments_key_bounds_aggregated(aggregated);
388
982
    }
389
390
201
    bool get_first_segment_key_bound(KeyBoundsPB* key_bounds) {
391
        // for compatibility, old version has not segment key bounds
392
201
        if (_rowset_meta_pb.segments_key_bounds_size() == 0) {
393
0
            return false;
394
0
        }
395
201
        *key_bounds = *_rowset_meta_pb.segments_key_bounds().begin();
396
201
        return true;
397
201
    }
398
399
138
    bool get_last_segment_key_bound(KeyBoundsPB* key_bounds) {
400
138
        if (_rowset_meta_pb.segments_key_bounds_size() == 0) {
401
0
            return false;
402
0
        }
403
138
        *key_bounds = *_rowset_meta_pb.segments_key_bounds().rbegin();
404
138
        return true;
405
138
    }
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
0
    void add_segment_key_bounds(KeyBoundsPB segments_key_bounds) {
413
0
        *_rowset_meta_pb.add_segments_key_bounds() = std::move(segments_key_bounds);
414
0
        set_segments_overlap(OVERLAPPING);
415
0
    }
416
417
1.52k
    void set_newest_write_timestamp(int64_t timestamp) {
418
1.52k
        _rowset_meta_pb.set_newest_write_timestamp(timestamp);
419
1.52k
    }
420
421
965
    int64_t newest_write_timestamp() const { return _rowset_meta_pb.newest_write_timestamp(); }
422
423
    // for cloud only
424
269
    bool has_visible_ts_ms() const { return _rowset_meta_pb.has_visible_ts_ms(); }
425
268
    int64_t visible_ts_ms() const { return _rowset_meta_pb.visible_ts_ms(); }
426
269
    std::chrono::time_point<std::chrono::system_clock> visible_timestamp() const {
427
269
        using namespace std::chrono;
428
269
        if (has_visible_ts_ms()) {
429
268
            return time_point<system_clock>(milliseconds(visible_ts_ms()));
430
268
        }
431
1
        return system_clock::from_time_t(newest_write_timestamp());
432
269
    }
433
771
    void set_visible_ts_ms(int64_t visible_ts_ms) {
434
771
        _rowset_meta_pb.set_visible_ts_ms(visible_ts_ms);
435
771
    }
436
437
    void set_tablet_schema(const TabletSchemaSPtr& tablet_schema);
438
    void set_tablet_schema(const TabletSchemaPB& tablet_schema);
439
440
29.1k
    const TabletSchemaSPtr& tablet_schema() const { return _schema; }
441
442
1
    void set_txn_expiration(int64_t expiration) { _rowset_meta_pb.set_txn_expiration(expiration); }
443
444
894
    void set_compaction_level(int64_t compaction_level) {
445
894
        _rowset_meta_pb.set_compaction_level(compaction_level);
446
894
    }
447
448
21
    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
0
    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
0
    const auto& inverted_index_file_info() const {
464
0
        return _rowset_meta_pb.inverted_index_file_info();
465
0
    }
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
0
                                   int64_t size, int64_t packed_file_size) {
479
0
        auto* index_map = _rowset_meta_pb.mutable_packed_slice_locations();
480
0
        auto& index_pb = (*index_map)[segment_path];
481
0
        index_pb.set_packed_file_path(packed_file_path);
482
0
        index_pb.set_offset(offset);
483
0
        index_pb.set_size(size);
484
0
        index_pb.set_packed_file_size(packed_file_size);
485
0
    }
486
487
81
    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
0
    void set_encryption_algorithm(EncryptionAlgorithmPB algorithm) {
494
0
        _determine_encryption_once.call(
495
0
                [algorithm]() -> Result<EncryptionAlgorithmPB> { return algorithm; });
496
0
    }
497
498
1.23k
    TsoRange commit_tso() const {
499
1.23k
        const auto& commit_tso_pb = _rowset_meta_pb.commit_tso();
500
1.23k
        return {commit_tso_pb.start_tso(), commit_tso_pb.end_tso()};
501
1.23k
    }
502
503
24
    bool has_commit_tso() const { return _rowset_meta_pb.has_commit_tso(); }
504
505
31
    void set_commit_tso(const TsoRange& commit_tso) {
506
31
        auto* commit_tso_pb = _rowset_meta_pb.mutable_commit_tso();
507
31
        commit_tso_pb->set_start_tso(commit_tso.start_tso());
508
31
        commit_tso_pb->set_end_tso(commit_tso.end_tso());
509
31
    }
510
511
19
    void set_commit_tso(int64_t commit_tso) { set_commit_tso({commit_tso, commit_tso}); }
512
513
0
    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
0
        set_version({visible_version, visible_version});
518
0
        if (version_update_time_ms > 0) {
519
0
            set_visible_ts_ms(version_update_time_ms);
520
0
        }
521
0
    }
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