Coverage Report

Created: 2026-06-26 04:46

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