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