Coverage Report

Created: 2026-05-20 14:16

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/tablet/base_tablet.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 <gen_cpp/olap_common.pb.h>
21
22
#include <memory>
23
#include <mutex>
24
#include <shared_mutex>
25
#include <string>
26
27
#include "common/metrics/metrics.h"
28
#include "common/status.h"
29
#include "io/io_common.h"
30
#include "storage/iterators.h"
31
#include "storage/olap_common.h"
32
#include "storage/partial_update_info.h"
33
#include "storage/segment/segment.h"
34
#include "storage/tablet/tablet_fwd.h"
35
#include "storage/tablet/tablet_meta.h"
36
#include "storage/tablet/tablet_schema.h"
37
#include "storage/version_graph.h"
38
39
namespace doris {
40
struct RowSetSplits;
41
struct RowsetWriterContext;
42
class RowsetWriter;
43
class CalcDeleteBitmapToken;
44
class SegmentCacheHandle;
45
class RowIdConversion;
46
struct PartialUpdateInfo;
47
class PartialUpdateReadPlan;
48
struct CaptureRowsetOps;
49
struct CaptureRowsetResult;
50
struct TabletReadSource;
51
class FixedReadPlan;
52
53
struct TabletWithVersion {
54
    BaseTabletSPtr tablet;
55
    int64_t version;
56
};
57
58
enum class CompactionStage { NOT_SCHEDULED, PENDING, EXECUTING };
59
60
// Base class for all tablet classes
61
class BaseTablet : public std::enable_shared_from_this<BaseTablet> {
62
public:
63
    explicit BaseTablet(TabletMetaSharedPtr tablet_meta);
64
    virtual ~BaseTablet();
65
    BaseTablet(const BaseTablet&) = delete;
66
    BaseTablet& operator=(const BaseTablet&) = delete;
67
68
39.8M
    TabletState tablet_state() const { return _tablet_meta->tablet_state(); }
69
    Status set_tablet_state(TabletState state);
70
30.4k
    int64_t table_id() const { return _tablet_meta->table_id(); }
71
0
    size_t row_size() const { return _tablet_meta->tablet_schema()->row_size(); }
72
36
    int64_t index_id() const { return _tablet_meta->index_id(); }
73
1.89M
    int64_t partition_id() const { return _tablet_meta->partition_id(); }
74
10.6M
    int64_t tablet_id() const { return _tablet_meta->tablet_id(); }
75
510k
    int32_t schema_hash() const { return _tablet_meta->schema_hash(); }
76
0
    CompressKind compress_kind() const { return _tablet_meta->tablet_schema()->compress_kind(); }
77
3.66M
    KeysType keys_type() const { return _tablet_meta->tablet_schema()->keys_type(); }
78
4.97M
    size_t num_key_columns() const { return _tablet_meta->tablet_schema()->num_key_columns(); }
79
360k
    int64_t ttl_seconds() const { return _tablet_meta->ttl_seconds(); }
80
    // currently used by schema change, inverted index building, and cooldown
81
24
    std::timed_mutex& get_schema_change_lock() { return _schema_change_lock; }
82
2.02M
    bool enable_unique_key_merge_on_write() const {
83
#ifdef BE_TEST
84
        if (_tablet_meta == nullptr) {
85
            return false;
86
        }
87
#endif
88
2.02M
        return _tablet_meta->enable_unique_key_merge_on_write();
89
2.02M
    }
90
91
    // Property encapsulated in TabletMeta
92
368M
    const TabletMetaSharedPtr& tablet_meta() { return _tablet_meta; }
93
94
    int32_t max_version_config();
95
96
    // FIXME(plat1ko): It is not appropriate to expose this lock
97
405k
    std::shared_mutex& get_header_lock() { return _meta_lock; }
98
99
    void update_max_version_schema(const TabletSchemaSPtr& tablet_schema);
100
101
421k
    TabletSchemaSPtr tablet_schema() const {
102
421k
        std::shared_lock rlock(_meta_lock);
103
421k
        return _max_version_schema;
104
421k
    }
105
106
9
    TabletSchemaSPtr row_binlog_tablet_schema() const {
107
9
        std::shared_lock rlock(_meta_lock);
108
9
        return _tablet_meta->row_binlog_schema();
109
9
    }
110
111
6
    void set_alter_failed(bool alter_failed) { _alter_failed = alter_failed; }
112
0
    bool is_alter_failed() { return _alter_failed; }
113
114
    virtual std::string tablet_path() const = 0;
115
116
    virtual bool exceed_version_limit(int32_t limit) = 0;
117
118
    virtual Result<std::unique_ptr<RowsetWriter>> create_rowset_writer(RowsetWriterContext& context,
119
                                                                       bool vertical) = 0;
120
121
    virtual Status capture_rs_readers(const Version& spec_version,
122
                                      std::vector<RowSetSplits>* rs_splits,
123
                                      const CaptureRowsetOps& opts) = 0;
124
125
    virtual size_t tablet_footprint() = 0;
126
127
    // this method just return the compaction sum on each rowset
128
    // note(tsy): we should unify the compaction score calculation finally
129
    uint32_t get_real_compaction_score() const;
130
131
    // MUST hold shared meta lock
132
    Status capture_rs_readers_unlocked(const Versions& version_path,
133
                                       std::vector<RowSetSplits>* rs_splits) const;
134
135
    // _rs_version_map and _stale_rs_version_map should be protected by _meta_lock
136
    // The caller must call hold _meta_lock when call this three function.
137
    RowsetSharedPtr get_rowset_by_version(const Version& version, bool find_is_stale = false) const;
138
    RowsetSharedPtr get_stale_rowset_by_version(const Version& version) const;
139
    RowsetSharedPtr get_rowset_with_max_version() const;
140
141
    Status get_all_rs_id(int64_t max_version, RowsetIdUnorderedSet* rowset_ids) const;
142
    Status get_all_rs_id_unlocked(int64_t max_version, RowsetIdUnorderedSet* rowset_ids) const;
143
144
    // Get the missed versions until the spec_version.
145
    Versions get_missed_versions(int64_t spec_version) const;
146
    Versions get_missed_versions_unlocked(int64_t spec_version,
147
                                          bool capture_row_binlog = false) const;
148
149
    void generate_tablet_meta_copy(TabletMeta& new_tablet_meta, bool cloud_get_rowset_meta) const;
150
    void generate_tablet_meta_copy_unlocked(TabletMeta& new_tablet_meta,
151
                                            bool cloud_get_rowset_meta) const;
152
153
46.3k
    virtual int64_t max_version_unlocked() const { return _tablet_meta->max_version().second; }
154
155
    static TabletSchemaSPtr tablet_schema_with_merged_max_schema_version(
156
            const std::vector<RowsetMetaSharedPtr>& rowset_metas);
157
158
    ////////////////////////////////////////////////////////////////////////////
159
    // begin MoW functions
160
    ////////////////////////////////////////////////////////////////////////////
161
    std::vector<RowsetSharedPtr> get_rowset_by_ids(
162
            const RowsetIdUnorderedSet* specified_rowset_ids);
163
164
    // Lookup a row with TupleDescriptor and fill Block
165
    Status lookup_row_data(const Slice& encoded_key, const RowLocation& row_location,
166
                           RowsetSharedPtr rowset, OlapReaderStatistics& stats, std::string& values,
167
                           bool write_to_cache = false);
168
    // Lookup the row location of `encoded_key`, the function sets `row_location` on success.
169
    // NOTE: the method only works in unique key model with primary key index, you will got a
170
    //       not supported error in other data model.
171
    Status lookup_row_key(const Slice& encoded_key, TabletSchema* latest_schema, bool with_seq_col,
172
                          const std::vector<RowsetSharedPtr>& specified_rowsets,
173
                          RowLocation* row_location, int64_t version,
174
                          std::vector<std::unique_ptr<SegmentCacheHandle>>& segment_caches,
175
                          RowsetSharedPtr* rowset = nullptr, bool with_rowid = true,
176
                          std::string* encoded_seq_value = nullptr,
177
                          OlapReaderStatistics* stats = nullptr,
178
                          DeleteBitmapPtr tablet_delete_bitmap = nullptr);
179
180
    // calc delete bitmap when flush memtable, use a fake version to calc
181
    // For example, cur max version is 5, and we use version 6 to calc but
182
    // finally this rowset publish version with 8, we should make up data
183
    // for rowset 6-7. Also, if a compaction happens between commit_txn and
184
    // publish_txn, we should remove compaction input rowsets' delete_bitmap
185
    // and build newly generated rowset's delete_bitmap
186
    static Status calc_delete_bitmap(const BaseTabletSPtr& tablet, RowsetSharedPtr rowset,
187
                                     const std::vector<segment_v2::SegmentSharedPtr>& segments,
188
                                     const std::vector<RowsetSharedPtr>& specified_rowsets,
189
                                     DeleteBitmapPtr delete_bitmap, int64_t version,
190
                                     CalcDeleteBitmapToken* token,
191
                                     RowsetWriter* rowset_writer = nullptr,
192
                                     DeleteBitmapPtr tablet_delete_bitmap = nullptr);
193
194
    Status calc_segment_delete_bitmap(RowsetSharedPtr rowset,
195
                                      const segment_v2::SegmentSharedPtr& seg,
196
                                      const std::vector<RowsetSharedPtr>& specified_rowsets,
197
                                      DeleteBitmapPtr delete_bitmap, int64_t end_version,
198
                                      RowsetWriter* rowset_writer,
199
                                      DeleteBitmapPtr tablet_delete_bitmap = nullptr);
200
201
    Status calc_delete_bitmap_between_segments(
202
            TabletSchemaSPtr schema, RowsetId rowset_id,
203
            const std::vector<segment_v2::SegmentSharedPtr>& segments,
204
            DeleteBitmapPtr delete_bitmap);
205
206
    static Status commit_phase_update_delete_bitmap(
207
            const BaseTabletSPtr& tablet, const RowsetSharedPtr& rowset,
208
            RowsetIdUnorderedSet& pre_rowset_ids, DeleteBitmapPtr delete_bitmap,
209
            const std::vector<segment_v2::SegmentSharedPtr>& segments, int64_t txn_id,
210
            CalcDeleteBitmapToken* token, RowsetWriter* rowset_writer = nullptr);
211
212
    static void add_sentinel_mark_to_delete_bitmap(DeleteBitmap* delete_bitmap,
213
                                                   const RowsetIdUnorderedSet& rowsetids);
214
215
    Status check_delete_bitmap_correctness(DeleteBitmapPtr delete_bitmap, int64_t max_version,
216
                                           int64_t txn_id, const RowsetIdUnorderedSet& rowset_ids,
217
                                           std::vector<RowsetSharedPtr>* rowsets = nullptr);
218
219
    static const signed char* get_delete_sign_column_data(const Block& block,
220
                                                          size_t rows_at_least = 0);
221
222
    static Status generate_default_value_block(const TabletSchema& schema,
223
                                               const std::vector<uint32_t>& cids,
224
                                               const std::vector<std::string>& default_values,
225
                                               const Block& ref_block, Block& default_value_block);
226
227
    static Status generate_new_block_for_partial_update(
228
            TabletSchemaSPtr rowset_schema, const PartialUpdateInfo* partial_update_info,
229
            const FixedReadPlan& read_plan_ori, const FixedReadPlan& read_plan_update,
230
            const std::map<RowsetId, RowsetSharedPtr>& rsid_to_rowset, Block* output_block);
231
232
    static Status generate_new_block_for_flexible_partial_update(
233
            TabletSchemaSPtr rowset_schema, const PartialUpdateInfo* partial_update_info,
234
            std::set<uint32_t>& rids_be_overwritten, const FixedReadPlan& read_plan_ori,
235
            const FixedReadPlan& read_plan_update,
236
            const std::map<RowsetId, RowsetSharedPtr>& rsid_to_rowset, Block* output_block);
237
238
    // We use the TabletSchema from the caller because the TabletSchema in the rowset'meta
239
    // may be outdated due to schema change. Also note that the the cids should indicate the indexes
240
    // of the columns in the TabletSchema passed in.
241
    static Status fetch_value_through_row_column(RowsetSharedPtr input_rowset,
242
                                                 const TabletSchema& tablet_schema, uint32_t segid,
243
                                                 const std::vector<uint32_t>& rowids,
244
                                                 const std::vector<uint32_t>& cids, Block& block);
245
246
    static Status fetch_value_by_rowids(RowsetSharedPtr input_rowset, uint32_t segid,
247
                                        const std::vector<uint32_t>& rowids,
248
                                        const TabletColumn& tablet_column, MutableColumnPtr& dst);
249
250
    virtual Result<std::unique_ptr<RowsetWriter>> create_transient_rowset_writer(
251
            const Rowset& rowset, std::shared_ptr<PartialUpdateInfo> partial_update_info,
252
            int64_t txn_expiration = 0) = 0;
253
254
    static Status update_delete_bitmap(const BaseTabletSPtr& self, TabletTxnInfo* txn_info,
255
                                       int64_t txn_id, int64_t txn_expiration = 0,
256
                                       DeleteBitmapPtr tablet_delete_bitmap = nullptr);
257
    virtual Status save_delete_bitmap(const TabletTxnInfo* txn_info, int64_t txn_id,
258
                                      DeleteBitmapPtr delete_bitmap, RowsetWriter* rowset_writer,
259
                                      const RowsetIdUnorderedSet& cur_rowset_ids,
260
                                      int64_t lock_id = -1, int64_t next_visible_version = -1) = 0;
261
    virtual CalcDeleteBitmapExecutor* calc_delete_bitmap_executor() = 0;
262
263
    void calc_compaction_output_rowset_delete_bitmap(
264
            const std::vector<RowsetSharedPtr>& input_rowsets,
265
            const RowIdConversion& rowid_conversion, uint64_t start_version, uint64_t end_version,
266
            std::set<RowLocation>* missed_rows,
267
            std::map<RowsetSharedPtr, std::list<std::pair<RowLocation, RowLocation>>>* location_map,
268
            const DeleteBitmap& input_delete_bitmap, DeleteBitmap* output_rowset_delete_bitmap);
269
270
    Status check_rowid_conversion(
271
            RowsetSharedPtr dst_rowset,
272
            const std::map<RowsetSharedPtr, std::list<std::pair<RowLocation, RowLocation>>>&
273
                    location_map);
274
275
    static Status update_delete_bitmap_without_lock(
276
            const BaseTabletSPtr& self, const RowsetSharedPtr& rowset,
277
            const std::vector<RowsetSharedPtr>* specified_base_rowsets = nullptr);
278
279
    using DeleteBitmapKeyRanges =
280
            std::vector<std::tuple<DeleteBitmap::BitmapKey, DeleteBitmap::BitmapKey>>;
281
    void agg_delete_bitmap_for_stale_rowsets(
282
            Version version, DeleteBitmapKeyRanges& remove_delete_bitmap_key_ranges);
283
    void check_agg_delete_bitmap_for_stale_rowsets(int64_t& useless_rowset_count,
284
                                                   int64_t& useless_rowset_version_count);
285
    ////////////////////////////////////////////////////////////////////////////
286
    // end MoW functions
287
    ////////////////////////////////////////////////////////////////////////////
288
289
    RowsetSharedPtr get_rowset(const RowsetId& rowset_id);
290
291
    std::vector<RowsetSharedPtr> get_snapshot_rowset(bool include_stale_rowset = false) const;
292
293
    virtual void clear_cache() = 0;
294
295
    // Find the first consecutive empty rowsets. output->size() >= limit
296
    void calc_consecutive_empty_rowsets(std::vector<RowsetSharedPtr>* empty_rowsets,
297
                                        const std::vector<RowsetSharedPtr>& candidate_rowsets,
298
                                        int64_t limit);
299
300
    void traverse_rowsets(std::function<void(const RowsetSharedPtr&)> visitor,
301
263k
                          bool include_stale = false) {
302
263k
        std::shared_lock rlock(_meta_lock);
303
263k
        traverse_rowsets_unlocked(visitor, include_stale);
304
263k
    }
305
306
    void traverse_rowsets_unlocked(std::function<void(const RowsetSharedPtr&)> visitor,
307
263k
                                   bool include_stale = false) const {
308
446k
        for (auto& [v, rs] : _rs_version_map) {
309
446k
            visitor(rs);
310
446k
        }
311
263k
        if (!include_stale) return;
312
261k
        for (auto& [v, rs] : _stale_rs_version_map) {
313
19.0k
            visitor(rs);
314
19.0k
        }
315
261k
    }
316
317
    Status calc_file_crc(uint32_t* crc_value, int64_t start_version, int64_t end_version,
318
                         uint32_t* rowset_count, int64_t* file_count);
319
320
    Status show_nested_index_file(std::string* json_meta);
321
322
2.28M
    TabletUid tablet_uid() const { return _tablet_meta->tablet_uid(); }
323
289k
    TabletInfo get_tablet_info() const { return TabletInfo(tablet_id(), tablet_uid()); }
324
325
    void get_base_rowset_delete_bitmap_count(
326
            uint64_t* max_base_rowset_delete_bitmap_score,
327
            int64_t* max_base_rowset_delete_bitmap_score_tablet_id);
328
329
16.2k
    virtual Status check_delete_bitmap_cache(int64_t txn_id, DeleteBitmap* expected_delete_bitmap) {
330
16.2k
        return Status::OK();
331
16.2k
    }
332
333
    void prefill_dbm_agg_cache(const RowsetSharedPtr& rowset, int64_t version);
334
    void prefill_dbm_agg_cache_after_compaction(const RowsetSharedPtr& output_rowset);
335
336
    [[nodiscard]] Result<CaptureRowsetResult> capture_consistent_rowsets_unlocked(
337
            const Version& version_range, const CaptureRowsetOps& options) const;
338
339
    [[nodiscard]] virtual Result<std::vector<Version>> capture_consistent_versions_unlocked(
340
            const Version& version_range, const CaptureRowsetOps& options) const;
341
342
    [[nodiscard]] Result<std::vector<RowSetSplits>> capture_rs_readers_unlocked(
343
            const Version& version_range, const CaptureRowsetOps& options) const;
344
345
    [[nodiscard]] Result<TabletReadSource> capture_read_source(const Version& version_range,
346
                                                               const CaptureRowsetOps& options);
347
348
protected:
349
    // Find the missed versions until the spec_version.
350
    //
351
    // for example:
352
    //     [0-4][5-5][8-8][9-9][14-14]
353
    // for cloud, if spec_version = 12, it will return [6-7],[10-12]
354
    // for local, if spec_version = 12, it will return [6, 6], [7, 7], [10, 10], [11, 11], [12, 12]
355
    virtual Versions calc_missed_versions(int64_t spec_version,
356
                                          Versions existing_versions) const = 0;
357
358
    void _print_missed_versions(const Versions& missed_versions) const;
359
    bool _reconstruct_version_tracker_if_necessary();
360
361
    static void _rowset_ids_difference(const RowsetIdUnorderedSet& cur,
362
                                       const RowsetIdUnorderedSet& pre,
363
                                       RowsetIdUnorderedSet* to_add, RowsetIdUnorderedSet* to_del);
364
365
    // We can only know if a key is excluded from the segment
366
    // based on strictly order compare result with segments key bounds
367
    static bool _key_is_not_in_segment(Slice key, const KeyBoundsPB& segment_key_bounds,
368
                                       bool is_segments_key_bounds_truncated);
369
370
    Status sort_block(Block& in_block, Block& output_block);
371
372
    Result<CaptureRowsetResult> _remote_capture_rowsets(const Version& version_range) const;
373
374
    mutable std::shared_mutex _meta_lock;
375
    TimestampedVersionTracker _timestamped_version_tracker;
376
    TimestampedVersionTracker _row_binlog_version_tracker;
377
378
    // After version 0.13, all newly created rowsets are saved in _rs_version_map.
379
    // And if rowset being compacted, the old rowsets will be saved in _stale_rs_version_map;
380
    std::unordered_map<Version, RowsetSharedPtr, HashOfVersion> _rs_version_map;
381
    // This variable _stale_rs_version_map is used to record these rowsets which are be compacted.
382
    // These _stale rowsets are been removed when rowsets' pathVersion is expired,
383
    // this policy is judged and computed by TimestampedVersionTracker.
384
    std::unordered_map<Version, RowsetSharedPtr, HashOfVersion> _stale_rs_version_map;
385
    // for row_binlog
386
    std::unordered_map<Version, RowsetSharedPtr, HashOfVersion> _row_binlog_rs_version_map;
387
    const TabletMetaSharedPtr _tablet_meta;
388
    TabletSchemaSPtr _max_version_schema;
389
390
    // `_alter_failed` is used to indicate whether the tablet failed to perform a schema change
391
    std::atomic<bool> _alter_failed = false;
392
393
    // metrics of this tablet
394
    std::shared_ptr<MetricEntity> _metric_entity;
395
396
protected:
397
    std::timed_mutex _schema_change_lock;
398
399
public:
400
    IntCounter* query_scan_bytes = nullptr;
401
    IntCounter* query_scan_rows = nullptr;
402
    IntCounter* query_scan_count = nullptr;
403
    IntCounter* flush_bytes = nullptr;
404
    IntCounter* flush_finish_count = nullptr;
405
    std::atomic<int64_t> published_count = 0;
406
    std::atomic<int64_t> read_block_count = 0;
407
    std::atomic<int64_t> write_count = 0;
408
    std::atomic<int64_t> compaction_count = 0;
409
410
    CompactionStage compaction_stage = CompactionStage::NOT_SCHEDULED;
411
    // Separate sample_infos for each compaction type to avoid race condition
412
    // when different types of compaction run concurrently on the same tablet
413
    std::mutex cumu_sample_info_lock;
414
    std::mutex base_sample_info_lock;
415
    std::mutex full_sample_info_lock;
416
    std::vector<CompactionSampleInfo> cumu_sample_infos;
417
    std::vector<CompactionSampleInfo> base_sample_infos;
418
    std::vector<CompactionSampleInfo> full_sample_infos;
419
    Status last_compaction_status = Status::OK();
420
421
13.2k
    std::mutex& get_sample_info_lock(ReaderType reader_type) {
422
13.2k
        switch (reader_type) {
423
10.1k
        case ReaderType::READER_CUMULATIVE_COMPACTION:
424
10.1k
            return cumu_sample_info_lock;
425
1.70k
        case ReaderType::READER_BASE_COMPACTION:
426
1.70k
            return base_sample_info_lock;
427
1.50k
        case ReaderType::READER_FULL_COMPACTION:
428
1.50k
            return full_sample_info_lock;
429
0
        default:
430
            // For other compaction types, use base_sample_info_lock as default
431
0
            return base_sample_info_lock;
432
13.2k
        }
433
13.2k
    }
434
435
13.2k
    std::vector<CompactionSampleInfo>& get_sample_infos(ReaderType reader_type) {
436
13.2k
        switch (reader_type) {
437
10.1k
        case ReaderType::READER_CUMULATIVE_COMPACTION:
438
10.1k
            return cumu_sample_infos;
439
1.70k
        case ReaderType::READER_BASE_COMPACTION:
440
1.70k
            return base_sample_infos;
441
1.50k
        case ReaderType::READER_FULL_COMPACTION:
442
1.50k
            return full_sample_infos;
443
3
        default:
444
            // For other compaction types, use base_sample_infos as default
445
3
            return base_sample_infos;
446
13.2k
        }
447
13.2k
    }
448
449
    // Density ratio for sparse optimization (non_null_cells / total_cells)
450
    // Value range: [0.0, 1.0], smaller value means more sparse
451
    // Default 1.0 means no history data, will not enable sparse optimization initially
452
    std::atomic<double> compaction_density {1.0};
453
};
454
455
struct CaptureRowsetOps {
456
    bool skip_missing_versions = false;
457
    bool quiet = false;
458
    bool include_stale_rowsets = true;
459
    bool enable_fetch_rowsets_from_peers = false;
460
    bool capture_row_binlog = false;
461
462
    // ======== only take effect in cloud mode ========
463
464
    // Enable preference for cached/warmed-up rowsets when building version paths.
465
    // When enabled, the capture process will prioritize already cached rowsets
466
    // to avoid cold data reads and improve query performance.
467
    bool enable_prefer_cached_rowset {false};
468
469
    // Query freshness tolerance in milliseconds.
470
    // Defines the time window for considering data as "fresh enough".
471
    // Rowsets that became visible within this time range can be skipped if not warmed up,
472
    // but older rowsets (before current_time - query_freshness_tolerance_ms) that are
473
    // not warmed up will trigger fallback to normal capture.
474
    // Set to -1 to disable freshness tolerance checking.
475
    int64_t query_freshness_tolerance_ms {-1};
476
};
477
478
struct CaptureRowsetResult {
479
    std::vector<RowsetSharedPtr> rowsets;
480
    std::shared_ptr<DeleteBitmap> delete_bitmap;
481
};
482
483
struct TabletReadSource {
484
    std::vector<RowSetSplits> rs_splits;
485
    std::vector<RowsetMetaSharedPtr> delete_predicates;
486
    std::shared_ptr<DeleteBitmap> delete_bitmap;
487
    // Fill delete predicates with `rs_splits`
488
    void fill_delete_predicates();
489
};
490
491
} /* namespace doris */