be/src/runtime/runtime_state.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 | | // This file is copied from |
18 | | // https://github.com/apache/impala/blob/branch-2.9.0/be/src/runtime/runtime-state.h |
19 | | // and modified by Doris |
20 | | |
21 | | #pragma once |
22 | | |
23 | | #include <gen_cpp/PaloInternalService_types.h> |
24 | | #include <gen_cpp/Types_types.h> |
25 | | #include <stdint.h> |
26 | | |
27 | | #include <atomic> |
28 | | #include <cstdint> |
29 | | #include <fstream> |
30 | | #include <functional> |
31 | | #include <memory> |
32 | | #include <mutex> |
33 | | #include <shared_mutex> |
34 | | #include <string> |
35 | | #include <vector> |
36 | | |
37 | | #include "agent/be_exec_version_manager.h" |
38 | | #include "cctz/time_zone.h" |
39 | | #include "common/be_mock_util.h" |
40 | | #include "common/check.h" |
41 | | #include "common/compiler_util.h" // IWYU pragma: keep |
42 | | #include "common/config.h" |
43 | | #include "common/factory_creator.h" |
44 | | #include "common/status.h" |
45 | | #include "exec/scan/vector_search_user_params.h" |
46 | | #include "runtime/runtime_profile.h" |
47 | | #include "runtime/task_execution_context.h" |
48 | | #include "runtime/workload_group/workload_group_fwd.h" |
49 | | #include "util/debug_util.h" |
50 | | #include "util/timezone_utils.h" |
51 | | |
52 | | namespace doris { |
53 | | namespace segment_v2 { |
54 | | enum CompressionTypePB : int; |
55 | | } |
56 | | namespace io { |
57 | | class S3FileSystem; |
58 | | } // namespace io |
59 | | class RuntimeFilter; |
60 | | |
61 | 2.98M | inline int32_t get_execution_rpc_timeout_ms(int32_t execution_timeout_sec) { |
62 | 2.98M | return std::min(config::execution_max_rpc_timeout_sec, execution_timeout_sec) * 1000; |
63 | 2.98M | } |
64 | | |
65 | | class PipelineXLocalStateBase; |
66 | | class PipelineXSinkLocalStateBase; |
67 | | class PipelineFragmentContext; |
68 | | class PipelineTask; |
69 | | class Dependency; |
70 | | |
71 | | class DescriptorTbl; |
72 | | class ObjectPool; |
73 | | class ExecEnv; |
74 | | class IdFileMap; |
75 | | class RuntimeFilterMgr; |
76 | | class MemTrackerLimiter; |
77 | | class QueryContext; |
78 | | class RuntimeFilterConsumer; |
79 | | class RuntimeFilterProducer; |
80 | | class TaskExecutionContext; |
81 | | |
82 | | // Keep RuntimeState self-contained without importing the full frontend Thrift service header. |
83 | | class TReportExecStatusParams; |
84 | | class RuntimeState; |
85 | | |
86 | | // Owns a share of the external-file report budget until the prepared commit messages are |
87 | | // published. Destruction releases an unpublished reservation automatically. |
88 | | class ExternalFileReportReservation { |
89 | | public: |
90 | 5 | ExternalFileReportReservation() = default; |
91 | | ~ExternalFileReportReservation(); |
92 | | |
93 | | ExternalFileReportReservation(const ExternalFileReportReservation&) = delete; |
94 | | ExternalFileReportReservation& operator=(const ExternalFileReportReservation&) = delete; |
95 | | |
96 | | private: |
97 | | friend class RuntimeState; |
98 | | |
99 | | RuntimeState* _state = nullptr; |
100 | | size_t _reserved_bytes = 0; |
101 | | }; |
102 | | |
103 | | class ExternalFileReportState { |
104 | | friend class RuntimeState; |
105 | | |
106 | | private: |
107 | | std::mutex mutex; |
108 | | size_t serialized_commit_bytes = 0; |
109 | | bool ownership_may_have_transferred = false; |
110 | | std::vector<std::function<void()>> rejected_report_cleanups; |
111 | | }; |
112 | | |
113 | | enum class ExternalFileReportOutcome { ACKNOWLEDGED, REJECTED, AMBIGUOUS }; |
114 | | |
115 | | // A collection of items that are part of the global state of a |
116 | | // query and shared across all execution nodes of that query. |
117 | | class RuntimeState { |
118 | | ENABLE_FACTORY_CREATOR(RuntimeState); |
119 | | |
120 | | public: |
121 | | RuntimeState(const TPlanFragmentExecParams& fragment_exec_params, |
122 | | const TQueryOptions& query_options, const TQueryGlobals& query_globals, |
123 | | ExecEnv* exec_env, QueryContext* ctx, |
124 | | const std::shared_ptr<MemTrackerLimiter>& query_mem_tracker = nullptr); |
125 | | |
126 | | RuntimeState(const TUniqueId& instance_id, const TUniqueId& query_id, int32_t fragment_id, |
127 | | const TQueryOptions& query_options, const TQueryGlobals& query_globals, |
128 | | ExecEnv* exec_env, QueryContext* ctx); |
129 | | |
130 | | // Used by pipeline. This runtime state is only used for setup. |
131 | | RuntimeState(const TUniqueId& query_id, int32_t fragment_id, const TQueryOptions& query_options, |
132 | | const TQueryGlobals& query_globals, ExecEnv* exec_env, QueryContext* ctx); |
133 | | |
134 | | // Only used in the materialization phase of delayed materialization, |
135 | | // when there may be no corresponding QueryContext. |
136 | | RuntimeState(const TUniqueId& query_id, int32_t fragment_id, const TQueryOptions& query_options, |
137 | | const TQueryGlobals& query_globals, ExecEnv* exec_env, |
138 | | const std::shared_ptr<MemTrackerLimiter>& query_mem_tracker); |
139 | | |
140 | | // RuntimeState for executing expr in fe-support. |
141 | | RuntimeState(const TQueryOptions& query_options, const TQueryGlobals& query_globals); |
142 | | |
143 | | // for job task only |
144 | | RuntimeState(); |
145 | | |
146 | | // Empty d'tor to avoid issues with unique_ptr. |
147 | | MOCK_DEFINE(virtual) ~RuntimeState(); |
148 | | |
149 | | // Set per-query state. |
150 | | Status init(const TUniqueId& fragment_instance_id, const TQueryOptions& query_options, |
151 | | const TQueryGlobals& query_globals, ExecEnv* exec_env); |
152 | | |
153 | | // for ut and non-query. |
154 | | void set_exec_env(ExecEnv* exec_env) { _exec_env = exec_env; } |
155 | | |
156 | | // for ut and non-query. |
157 | | void init_mem_trackers(const std::string& name = "ut", const TUniqueId& id = TUniqueId()); |
158 | | |
159 | 38.0M | const TQueryOptions& query_options() const { return _query_options; } |
160 | 233k | int64_t scan_queue_mem_limit() const { |
161 | 233k | return _query_options.__isset.scan_queue_mem_limit ? _query_options.scan_queue_mem_limit |
162 | 233k | : _query_options.mem_limit / 20; |
163 | 233k | } |
164 | | |
165 | 760k | bool enable_adjust_conjunct_order_by_cost() const { |
166 | 760k | return _query_options.__isset.enable_adjust_conjunct_order_by_cost && |
167 | 760k | _query_options.enable_adjust_conjunct_order_by_cost; |
168 | 760k | } |
169 | | |
170 | 235k | int32_t max_column_reader_num() const { |
171 | 235k | return _query_options.__isset.max_column_reader_num ? _query_options.max_column_reader_num |
172 | 235k | : 20000; |
173 | 235k | } |
174 | | |
175 | 6.73M | ObjectPool* obj_pool() const { return _obj_pool.get(); } |
176 | | |
177 | 5.17M | const DescriptorTbl& desc_tbl() const { return *_desc_tbl; } |
178 | 2.51M | void set_desc_tbl(const DescriptorTbl* desc_tbl) { _desc_tbl = desc_tbl; } |
179 | | |
180 | | // Row-count limit for output blocks. Clamp to [1, 65535]. |
181 | | // Adaptive byte budgeting still uses this as the hard row ceiling. |
182 | 27.5M | MOCK_FUNCTION int batch_size() const { |
183 | 27.5M | static constexpr int kMax = 65535; |
184 | 27.5M | auto v = _query_options.batch_size; |
185 | 27.5M | return std::min(std::max(1, v), kMax); |
186 | 27.5M | } |
187 | | |
188 | | // Target byte budget per output block (default 8MB when adaptive is enabled). |
189 | | // The public FE/session contract is [1MB, 512MB]; this accessor still clamps any direct |
190 | | // thrift or mixed-version out-of-range value into that range. Returns `kMax` when adaptive |
191 | | // is disabled by BE config so the value is always a legal byte budget; callers that need |
192 | | // to know whether adaptive batch size is active should test |
193 | | // `config::enable_adaptive_batch_size` explicitly. |
194 | 4.13M | MOCK_FUNCTION size_t preferred_block_size_bytes() const { |
195 | 4.13M | static constexpr int64_t kDefault = 8388608L; // 8MB |
196 | 4.13M | static constexpr int64_t kMax = 536870912L; // 512MB |
197 | 4.13M | static constexpr int64_t kMin = 1048576L; // 1MB |
198 | 4.13M | if (!config::enable_adaptive_batch_size) [[unlikely]] { |
199 | 8.24k | return kMax; |
200 | 8.24k | } |
201 | 4.13M | if (_query_options.__isset.preferred_block_size_bytes) [[likely]] { |
202 | 4.13M | return std::max<int64_t>( |
203 | 4.13M | kMin, std::min<int64_t>(_query_options.preferred_block_size_bytes, kMax)); |
204 | 4.13M | } |
205 | 18.4E | return kDefault; |
206 | 4.12M | } |
207 | | |
208 | 978k | int query_parallel_instance_num() const { return _query_options.parallel_instance; } |
209 | 0 | int max_errors() const { return _query_options.max_errors; } |
210 | 3.28M | int execution_timeout() const { |
211 | 3.28M | return _query_options.__isset.execution_timeout ? _query_options.execution_timeout |
212 | 18.4E | : _query_options.query_timeout; |
213 | 3.28M | } |
214 | 452k | int max_scanners_concurrency() const { |
215 | 452k | return _query_options.__isset.max_scanners_concurrency |
216 | 453k | ? _query_options.max_scanners_concurrency |
217 | 18.4E | : 0; |
218 | 452k | } |
219 | 12.1k | int max_file_scanners_concurrency() const { |
220 | 12.1k | return _query_options.__isset.max_file_scanners_concurrency |
221 | 12.1k | ? _query_options.max_file_scanners_concurrency |
222 | 18.4E | : max_scanners_concurrency(); |
223 | 12.1k | } |
224 | | |
225 | 454k | int min_scanners_concurrency() const { |
226 | 454k | return _query_options.__isset.min_scanners_concurrency |
227 | 455k | ? _query_options.min_scanners_concurrency |
228 | 18.4E | : 1; |
229 | 454k | } |
230 | | |
231 | 4.03k | int min_file_scanners_concurrency() const { |
232 | 4.03k | return _query_options.__isset.min_file_scanners_concurrency |
233 | 4.03k | ? _query_options.min_file_scanners_concurrency |
234 | 18.4E | : 1; |
235 | 4.03k | } |
236 | | |
237 | | // Support extended regex |
238 | | // like look-around zero-width assertions(`?=`, `?!`, `?<=`, `?<!`) |
239 | 8.83k | bool enable_extended_regex() const { |
240 | 8.83k | return _query_options.__isset.enable_extended_regex && _query_options.enable_extended_regex; |
241 | 8.83k | } |
242 | | |
243 | 98.5k | TQueryType::type query_type() const { return _query_options.query_type; } |
244 | 49.4k | int64_t timestamp_ms() const { return _timestamp_ms; } |
245 | 49.3k | int32_t nano_seconds() const { return _nano_seconds; } |
246 | | // if possible, use timezone_obj() rather than timezone() |
247 | 263k | const std::string& timezone() const { return _timezone; } |
248 | 337k | const cctz::time_zone& timezone_obj() const { return _timezone_obj; } |
249 | 502 | void set_timezone(const std::string& timezone) { |
250 | 502 | _timezone = timezone; |
251 | 502 | DORIS_CHECK(TimezoneUtils::find_cctz_time_zone(_timezone, _timezone_obj)); |
252 | 502 | } |
253 | 511 | const std::string& lc_time_names() const { return _lc_time_names; } |
254 | 13.0M | const TUniqueId& query_id() const { return _query_id; } |
255 | 2.35M | const TUniqueId& fragment_instance_id() const { return _fragment_instance_id; } |
256 | | // should only be called in pipeline engine |
257 | 1.04k | int32_t fragment_id() const { return _fragment_id; } |
258 | 3.84M | ExecEnv* exec_env() { return _exec_env; } |
259 | | std::shared_ptr<MemTrackerLimiter> query_mem_tracker() const; |
260 | | |
261 | | // Returns runtime state profile |
262 | 1.70k | RuntimeProfile* runtime_profile() { return &_profile; } |
263 | 74.8k | RuntimeProfile* load_channel_profile() { return &_load_channel_profile; } |
264 | | |
265 | 304k | bool enable_function_pushdown() const { |
266 | 304k | return _query_options.__isset.enable_function_pushdown && |
267 | 304k | _query_options.enable_function_pushdown; |
268 | 304k | } |
269 | | |
270 | 733k | bool check_overflow_for_decimal() const { |
271 | 733k | return _query_options.__isset.check_overflow_for_decimal && |
272 | 733k | _query_options.check_overflow_for_decimal; |
273 | 733k | } |
274 | | |
275 | 738k | bool enable_strict_mode() const { |
276 | 738k | return _query_options.__isset.enable_strict_cast && _query_options.enable_strict_cast; |
277 | 738k | } |
278 | | |
279 | 107 | bool enable_insert_strict() const { |
280 | 107 | return _query_options.__isset.enable_insert_strict && _query_options.enable_insert_strict; |
281 | 107 | } |
282 | | |
283 | 942k | bool enable_segment_limit_pushdown() const { |
284 | 942k | return !_query_options.__isset.enable_segment_limit_pushdown || |
285 | 946k | _query_options.enable_segment_limit_pushdown; |
286 | 942k | } |
287 | | |
288 | 402k | bool mysql_row_binary_format() const { |
289 | 402k | return _query_options.__isset.mysql_row_binary_format && |
290 | 402k | _query_options.mysql_row_binary_format; |
291 | 402k | } |
292 | | |
293 | 22 | bool enable_short_circuit_query_access_column_store() const { |
294 | 22 | return _query_options.__isset.enable_short_circuit_query_access_column_store && |
295 | 22 | _query_options.enable_short_circuit_query_access_column_store; |
296 | 22 | } |
297 | | |
298 | | // Appends error to the _error_log if there is space |
299 | | bool log_error(const std::string& error); |
300 | | |
301 | | // Returns true if the error log has not reached _max_errors. |
302 | 0 | bool log_has_space() { |
303 | 0 | std::lock_guard<std::mutex> l(_error_log_lock); |
304 | 0 | return _error_log.size() < _query_options.max_errors; |
305 | 0 | } |
306 | | |
307 | | // Append all _error_log[_unreported_error_idx+] to new_errors and set |
308 | | // _unreported_error_idx to _errors_log.size() |
309 | | void get_unreported_errors(std::vector<std::string>* new_errors); |
310 | | |
311 | | [[nodiscard]] MOCK_FUNCTION bool is_cancelled() const; |
312 | | MOCK_FUNCTION Status cancel_reason() const; |
313 | 36 | void cancel(const Status& reason) { |
314 | 36 | if (_exec_status.update(reason)) { |
315 | | // Create a error status, so that we could print error stack, and |
316 | | // we could know which path call cancel. |
317 | 36 | LOG(WARNING) << "Task is cancelled, instance: " |
318 | 36 | << PrintInstanceStandardInfo(_query_id, _fragment_instance_id) |
319 | 36 | << ", st = " << reason; |
320 | 36 | } else { |
321 | 0 | LOG(WARNING) << "Task is already cancelled, instance: " |
322 | 0 | << PrintInstanceStandardInfo(_query_id, _fragment_instance_id) |
323 | 0 | << ", original cancel msg: " << _exec_status.status() |
324 | 0 | << ", new cancel msg: " << reason; |
325 | 0 | } |
326 | 36 | } |
327 | | |
328 | 2.19M | void set_backend_id(int64_t backend_id) { _backend_id = backend_id; } |
329 | 54 | int64_t backend_id() const { return _backend_id; } |
330 | | |
331 | 1.83M | void set_be_number(int be_number) { _be_number = be_number; } |
332 | 4.50M | int be_number(void) const { return _be_number; } |
333 | | |
334 | 6.55k | std::vector<std::string>& output_files() { return _output_files; } |
335 | | |
336 | 1.73k | void set_import_label(const std::string& import_label) { _import_label = import_label; } |
337 | | |
338 | 201k | const std::vector<std::string>& export_output_files() const { return _export_output_files; } |
339 | | |
340 | 0 | void add_export_output_file(const std::string& file) { _export_output_files.push_back(file); } |
341 | | |
342 | 505 | void set_db_name(const std::string& db_name) { _db_name = db_name; } |
343 | | |
344 | 0 | const std::string& db_name() { return _db_name; } |
345 | | |
346 | 1.26k | void set_wal_id(int64_t wal_id) { _wal_id = wal_id; } |
347 | | |
348 | 156k | int64_t wal_id() const { return _wal_id; } |
349 | | |
350 | 431 | void set_content_length(size_t content_length) { _content_length = content_length; } |
351 | | |
352 | 4 | size_t content_length() const { return _content_length; } |
353 | | |
354 | 601 | const std::string& import_label() { return _import_label; } |
355 | | |
356 | 0 | const std::string& load_dir() const { return _load_dir; } |
357 | | |
358 | 0 | void set_load_job_id(int64_t job_id) { _load_job_id = job_id; } |
359 | | |
360 | 48.8k | int64_t load_job_id() const { return _load_job_id; } |
361 | | |
362 | | std::string get_error_log_file_path(); |
363 | | |
364 | | std::string get_first_error_msg() const; |
365 | | |
366 | | // append error msg and error line to file when loading data. |
367 | | // is_summary is true, means we are going to write the summary line |
368 | | // If we need to stop the processing, set stop_processing to true |
369 | | Status append_error_msg_to_file(std::function<std::string()> line, |
370 | | std::function<std::string()> error_msg); |
371 | | |
372 | 75.4k | int64_t num_bytes_load_total() { return _num_bytes_load_total.load(); } |
373 | | |
374 | 201k | int64_t num_finished_range() { return _num_finished_scan_range.load(); } |
375 | | |
376 | 315k | int64_t num_rows_load_total() { return _num_rows_load_total.load(); } |
377 | | |
378 | 291k | int64_t num_rows_load_filtered() { return _num_rows_load_filtered.load(); } |
379 | | |
380 | 124k | int64_t num_rows_load_unselected() { return _num_rows_load_unselected.load(); } |
381 | | |
382 | 98.4k | int64_t num_rows_filtered_in_strict_mode_partial_update() { |
383 | 98.4k | return _num_rows_filtered_in_strict_mode_partial_update; |
384 | 98.4k | } |
385 | | |
386 | 36.8k | int64_t num_rows_load_success() { |
387 | 36.8k | return num_rows_load_total() - num_rows_load_filtered() - num_rows_load_unselected(); |
388 | 36.8k | } |
389 | | |
390 | 43.4k | void update_num_rows_load_total(int64_t num_rows) { _num_rows_load_total.fetch_add(num_rows); } |
391 | | |
392 | 49.8k | void set_num_rows_load_total(int64_t num_rows) { _num_rows_load_total.store(num_rows); } |
393 | | |
394 | 43.4k | void update_num_bytes_load_total(int64_t bytes_load) { |
395 | 43.4k | _num_bytes_load_total.fetch_add(bytes_load); |
396 | 43.4k | } |
397 | | |
398 | 3.33k | void update_num_finished_scan_range(int64_t finished_range) { |
399 | 3.33k | _num_finished_scan_range.fetch_add(finished_range); |
400 | 3.33k | } |
401 | | |
402 | 52.6k | void update_num_rows_load_filtered(int64_t num_rows) { |
403 | 52.6k | _num_rows_load_filtered.fetch_add(num_rows); |
404 | 52.6k | } |
405 | | |
406 | 52.0k | void update_num_rows_load_unselected(int64_t num_rows) { |
407 | 52.0k | _num_rows_load_unselected.fetch_add(num_rows); |
408 | 52.0k | } |
409 | | |
410 | 72 | void set_num_rows_filtered_in_strict_mode_partial_update(int64_t num_rows) { |
411 | 72 | _num_rows_filtered_in_strict_mode_partial_update = num_rows; |
412 | 72 | } |
413 | | |
414 | 1.83M | void set_per_fragment_instance_idx(int idx) { _per_fragment_instance_idx = idx; } |
415 | | |
416 | 270k | int per_fragment_instance_idx() const { return _per_fragment_instance_idx; } |
417 | | |
418 | 2.19M | void set_num_per_fragment_instances(int num_instances) { |
419 | 2.19M | _num_per_fragment_instances = num_instances; |
420 | 2.19M | } |
421 | | |
422 | 48.8k | int num_per_fragment_instances() const { return _num_per_fragment_instances; } |
423 | | |
424 | 2.19M | void set_load_stream_per_node(int load_stream_per_node) { |
425 | 2.19M | _load_stream_per_node = load_stream_per_node; |
426 | 2.19M | } |
427 | | |
428 | 14 | int load_stream_per_node() const { return _load_stream_per_node; } |
429 | | |
430 | 2.19M | void set_total_load_streams(int total_load_streams) { |
431 | 2.19M | _total_load_streams = total_load_streams; |
432 | 2.19M | } |
433 | | |
434 | 14 | int total_load_streams() const { return _total_load_streams; } |
435 | | |
436 | 2.19M | void set_num_local_sink(int num_local_sink) { _num_local_sink = num_local_sink; } |
437 | | |
438 | 14 | int num_local_sink() const { return _num_local_sink; } |
439 | | |
440 | 0 | bool disable_stream_preaggregations() const { |
441 | 0 | return _query_options.disable_stream_preaggregations; |
442 | 0 | } |
443 | | |
444 | 0 | int32_t runtime_filter_wait_time_ms() const { |
445 | 0 | return _query_options.runtime_filter_wait_time_ms; |
446 | 0 | } |
447 | | |
448 | 1.85k | int32_t runtime_filter_max_in_num() const { return _query_options.runtime_filter_max_in_num; } |
449 | | |
450 | 18.7M | int be_exec_version() const { |
451 | 18.7M | DCHECK(_query_options.__isset.be_exec_version && |
452 | 18.7M | BeExecVersionManager::check_be_exec_version(_query_options.be_exec_version)); |
453 | 18.7M | return _query_options.be_exec_version; |
454 | 18.7M | } |
455 | 365k | bool plan_local_shuffle() const { |
456 | | // If local shuffle is enabled and not planned by local shuffle planner, we should plan local shuffle in BE. |
457 | 365k | return _query_options.__isset.enable_local_shuffle && _query_options.enable_local_shuffle && |
458 | 365k | (!_query_options.__isset.enable_local_shuffle_planner || |
459 | 362k | !_query_options.enable_local_shuffle_planner); |
460 | 365k | } |
461 | | |
462 | 2.97M | MOCK_FUNCTION bool enable_local_exchange() const { |
463 | 2.98M | return _query_options.__isset.enable_local_exchange && _query_options.enable_local_exchange; |
464 | 2.97M | } |
465 | | |
466 | 3.60k | bool trim_tailing_spaces_for_external_table_query() const { |
467 | 3.60k | return _query_options.trim_tailing_spaces_for_external_table_query; |
468 | 3.60k | } |
469 | | |
470 | 401k | bool return_object_data_as_binary() const { |
471 | 401k | return _query_options.return_object_data_as_binary; |
472 | 401k | } |
473 | | |
474 | 6.31M | bool enable_fuzzy_blockable_task() const { |
475 | 6.31M | return _query_options.__isset.enable_fuzzy_blockable_task && |
476 | 6.31M | _query_options.enable_fuzzy_blockable_task; |
477 | 6.31M | } |
478 | | |
479 | | segment_v2::CompressionTypePB fragement_transmission_compression_type() const; |
480 | | |
481 | 1.88M | bool skip_storage_engine_merge() const { |
482 | 1.88M | return _query_options.__isset.skip_storage_engine_merge && |
483 | 1.89M | _query_options.skip_storage_engine_merge; |
484 | 1.88M | } |
485 | | |
486 | 1.08M | bool skip_delete_predicate() const { |
487 | 1.08M | return _query_options.__isset.skip_delete_predicate && _query_options.skip_delete_predicate; |
488 | 1.08M | } |
489 | | |
490 | 950k | bool skip_delete_bitmap() const { |
491 | 951k | return _query_options.__isset.skip_delete_bitmap && _query_options.skip_delete_bitmap; |
492 | 950k | } |
493 | | |
494 | 1.08M | bool skip_missing_version() const { |
495 | 1.08M | return _query_options.__isset.skip_missing_version && _query_options.skip_missing_version; |
496 | 1.08M | } |
497 | | |
498 | 9.45k | int64_t data_queue_max_blocks() const { |
499 | 9.45k | return _query_options.__isset.data_queue_max_blocks ? _query_options.data_queue_max_blocks |
500 | 18.4E | : 1; |
501 | 9.45k | } |
502 | | |
503 | | bool enable_page_cache() const; |
504 | | |
505 | 1.06M | bool enable_prefer_cached_rowset() const { |
506 | 1.06M | return _query_options.__isset.enable_prefer_cached_rowset && |
507 | 1.06M | _query_options.enable_prefer_cached_rowset; |
508 | 1.06M | } |
509 | | |
510 | 1.06M | int64_t query_freshness_tolerance_ms() const { |
511 | 1.06M | return _query_options.query_freshness_tolerance_ms; |
512 | 1.06M | } |
513 | | |
514 | 0 | bool enable_query_freshness_tolerance() const { |
515 | 0 | return _query_options.__isset.query_freshness_tolerance_ms && |
516 | 0 | _query_options.query_freshness_tolerance_ms > 0; |
517 | 0 | } |
518 | | |
519 | 204k | std::vector<TTabletCommitInfo> tablet_commit_infos() const { |
520 | 204k | std::lock_guard<std::mutex> lock(_tablet_infos_mutex); |
521 | 204k | return _tablet_commit_infos; |
522 | 204k | } |
523 | | |
524 | 50.2k | void add_tablet_commit_infos(std::vector<TTabletCommitInfo>& commit_infos) { |
525 | 50.2k | std::lock_guard<std::mutex> lock(_tablet_infos_mutex); |
526 | 50.2k | _tablet_commit_infos.insert(_tablet_commit_infos.end(), |
527 | 50.2k | std::make_move_iterator(commit_infos.begin()), |
528 | 50.2k | std::make_move_iterator(commit_infos.end())); |
529 | 50.2k | } |
530 | | |
531 | 201k | std::vector<TErrorTabletInfo> error_tablet_infos() const { |
532 | 201k | std::lock_guard<std::mutex> lock(_tablet_infos_mutex); |
533 | 201k | return _error_tablet_infos; |
534 | 201k | } |
535 | | |
536 | 50.2k | void add_error_tablet_infos(std::vector<TErrorTabletInfo>& tablet_infos) { |
537 | 50.2k | std::lock_guard<std::mutex> lock(_tablet_infos_mutex); |
538 | 50.2k | _error_tablet_infos.insert(_error_tablet_infos.end(), |
539 | 50.2k | std::make_move_iterator(tablet_infos.begin()), |
540 | 50.2k | std::make_move_iterator(tablet_infos.end())); |
541 | 50.2k | } |
542 | | |
543 | 180k | std::vector<THivePartitionUpdate> hive_partition_updates() const { |
544 | 180k | std::lock_guard<std::mutex> lock(_hive_partition_updates_mutex); |
545 | 180k | return _hive_partition_updates; |
546 | 180k | } |
547 | | |
548 | 10 | void add_hive_partition_updates(const THivePartitionUpdate& hive_partition_update) { |
549 | 10 | std::lock_guard<std::mutex> lock(_hive_partition_updates_mutex); |
550 | 10 | _hive_partition_updates.emplace_back(hive_partition_update); |
551 | 10 | } |
552 | | |
553 | 181k | void append_iceberg_commit_datas(std::vector<TIcebergCommitData>* output) const { |
554 | 181k | std::lock_guard<std::mutex> lock(_iceberg_commit_datas_mutex); |
555 | 181k | output->insert(output->end(), _iceberg_commit_datas.begin(), _iceberg_commit_datas.end()); |
556 | 181k | } |
557 | | |
558 | | Status add_iceberg_commit_datas(TIcebergCommitData iceberg_commit_data); |
559 | | |
560 | | // Reserve report space before closing the Paimon writer, then either publish the prepared |
561 | | // messages after a clean close or let the reservation release itself while aborting the writer. |
562 | | Status reserve_paimon_commit_messages(const std::vector<TPaimonCommitMessage>& commit_messages, |
563 | | ExternalFileReportReservation* reservation); |
564 | | |
565 | | void publish_reserved_paimon_commit_messages(std::vector<TPaimonCommitMessage> commit_messages, |
566 | | ExternalFileReportReservation* reservation); |
567 | | |
568 | 181k | void append_paimon_commit_messages(std::vector<TPaimonCommitMessage>* output) const { |
569 | 181k | std::lock_guard<std::mutex> lock(_paimon_commit_messages_mutex); |
570 | 181k | output->insert(output->end(), _paimon_commit_messages.begin(), |
571 | 181k | _paimon_commit_messages.end()); |
572 | 181k | } |
573 | | |
574 | | size_t coordinator_thrift_message_limit() const; |
575 | | |
576 | | void append_external_file_commit_data(TReportExecStatusParams* params, bool final_report) const; |
577 | | |
578 | | void add_rejected_external_file_report_cleanup(std::function<void()> cleanup); |
579 | | |
580 | | void finalize_external_file_report_cleanup(ExternalFileReportOutcome outcome); |
581 | | |
582 | 1.83M | void set_external_file_report_state(std::shared_ptr<ExternalFileReportState> report_state) { |
583 | 1.83M | _external_file_report_state = std::move(report_state); |
584 | 1.83M | } |
585 | | |
586 | 1.83M | const std::shared_ptr<ExternalFileReportState>& external_file_report_state() const { |
587 | 1.83M | return _external_file_report_state; |
588 | 1.83M | } |
589 | | |
590 | 181k | std::vector<TMCCommitData> mc_commit_datas() const { |
591 | 181k | std::lock_guard<std::mutex> lock(_mc_commit_datas_mutex); |
592 | 181k | return _mc_commit_datas; |
593 | 181k | } |
594 | | |
595 | 1 | void add_mc_commit_datas(const TMCCommitData& mc_commit_data) { |
596 | 1 | std::lock_guard<std::mutex> lock(_mc_commit_datas_mutex); |
597 | 1 | _mc_commit_datas.emplace_back(mc_commit_data); |
598 | 1 | } |
599 | | |
600 | | // local runtime filter mgr, the runtime filter do not have remote target or |
601 | | // not need local merge should regist here. the instance exec finish, the local |
602 | | // runtime filter mgr can release the memory of local runtime filter |
603 | 85.1k | RuntimeFilterMgr* local_runtime_filter_mgr() { return _runtime_filter_mgr; } |
604 | | |
605 | | RuntimeFilterMgr* global_runtime_filter_mgr(); |
606 | | |
607 | 1.83M | void set_runtime_filter_mgr(RuntimeFilterMgr* runtime_filter_mgr) { |
608 | 1.83M | _runtime_filter_mgr = runtime_filter_mgr; |
609 | 1.83M | } |
610 | | |
611 | 78.0M | QueryContext* get_query_ctx() const { return _query_ctx; } |
612 | | |
613 | | [[nodiscard]] bool low_memory_mode() const; |
614 | | |
615 | | std::weak_ptr<QueryContext> get_query_ctx_weak(); |
616 | | MOCK_FUNCTION WorkloadGroupPtr workload_group(); |
617 | | |
618 | 1.83M | void set_query_mem_tracker(const std::shared_ptr<MemTrackerLimiter>& tracker) { |
619 | 1.83M | _query_mem_tracker = tracker; |
620 | 1.83M | } |
621 | | |
622 | 5.98k | void set_query_options(const TQueryOptions& query_options) { _query_options = query_options; } |
623 | | |
624 | 2.88M | bool enable_profile() const { |
625 | 2.88M | return _query_options.__isset.enable_profile && _query_options.enable_profile; |
626 | 2.88M | } |
627 | | |
628 | 169 | int cte_max_recursion_depth() const { |
629 | 169 | return _query_options.__isset.cte_max_recursion_depth |
630 | 169 | ? _query_options.cte_max_recursion_depth |
631 | 169 | : 0; |
632 | 169 | } |
633 | | |
634 | 1 | bool enable_streaming_agg_hash_join_force_passthrough() const { |
635 | 1 | return _query_options.__isset.enable_streaming_agg_hash_join_force_passthrough && |
636 | 1 | _query_options.enable_streaming_agg_hash_join_force_passthrough; |
637 | 1 | } |
638 | | |
639 | 29.7k | bool enable_local_exchange_before_agg() const { |
640 | 29.7k | return _query_options.__isset.enable_local_exchange_before_agg && |
641 | 29.7k | _query_options.enable_local_exchange_before_agg; |
642 | 29.7k | } |
643 | | |
644 | 1.37k | bool enable_local_exchange_before_streaming_agg() const { |
645 | 1.37k | return _query_options.__isset.enable_local_exchange_before_streaming_agg && |
646 | 1.37k | _query_options.enable_local_exchange_before_streaming_agg; |
647 | 1.37k | } |
648 | | |
649 | 7.38k | bool enable_distinct_streaming_agg_force_passthrough() const { |
650 | 7.38k | return _query_options.__isset.enable_distinct_streaming_agg_force_passthrough && |
651 | 7.38k | _query_options.enable_distinct_streaming_agg_force_passthrough; |
652 | 7.38k | } |
653 | | |
654 | 7.73k | bool enable_broadcast_join_force_passthrough() const { |
655 | 7.73k | return _query_options.__isset.enable_broadcast_join_force_passthrough && |
656 | 7.73k | _query_options.enable_broadcast_join_force_passthrough; |
657 | 7.73k | } |
658 | | |
659 | 323k | int rpc_verbose_profile_max_instance_count() const { |
660 | 323k | return _query_options.__isset.rpc_verbose_profile_max_instance_count |
661 | 323k | ? _query_options.rpc_verbose_profile_max_instance_count |
662 | 18.4E | : 0; |
663 | 323k | } |
664 | | |
665 | 15.3k | MOCK_FUNCTION bool enable_share_hash_table_for_broadcast_join() const { |
666 | 15.3k | return _query_options.__isset.enable_share_hash_table_for_broadcast_join && |
667 | 15.3k | _query_options.enable_share_hash_table_for_broadcast_join; |
668 | 15.3k | } |
669 | | |
670 | 245k | bool enable_parallel_scan() const { |
671 | 246k | return _query_options.__isset.enable_parallel_scan && _query_options.enable_parallel_scan; |
672 | 245k | } |
673 | | |
674 | 121k | bool enable_aggregate_function_null_v2() const { |
675 | 121k | return _query_options.__isset.enable_aggregate_function_null_v2 && |
676 | 121k | _query_options.enable_aggregate_function_null_v2; |
677 | 121k | } |
678 | | |
679 | 1.24M | bool enable_prune_nested_column() const { |
680 | 1.24M | return _query_options.__isset.enable_prune_nested_column && |
681 | 1.24M | _query_options.enable_prune_nested_column; |
682 | 1.24M | } |
683 | | |
684 | 28 | bool is_read_csv_empty_line_as_null() const { |
685 | 28 | return _query_options.__isset.read_csv_empty_line_as_null && |
686 | 28 | _query_options.read_csv_empty_line_as_null; |
687 | 28 | } |
688 | | |
689 | 113k | int parallel_scan_max_scanners_count() const { |
690 | 113k | return _query_options.__isset.parallel_scan_max_scanners_count |
691 | 113k | ? _query_options.parallel_scan_max_scanners_count |
692 | 18.4E | : 0; |
693 | 113k | } |
694 | | |
695 | 47.6k | int partition_topn_max_partitions() const { |
696 | 47.6k | return _query_options.__isset.partition_topn_max_partitions |
697 | 47.6k | ? _query_options.partition_topn_max_partitions |
698 | 47.6k | : 1024; |
699 | 47.6k | } |
700 | | |
701 | 0 | int partition_topn_per_partition_rows() const { |
702 | 0 | return _query_options.__isset.partition_topn_pre_partition_rows |
703 | 0 | ? _query_options.partition_topn_pre_partition_rows |
704 | 0 | : 1000; |
705 | 0 | } |
706 | | |
707 | 113k | int64_t parallel_scan_min_rows_per_scanner() const { |
708 | 113k | return _query_options.__isset.parallel_scan_min_rows_per_scanner |
709 | 113k | ? _query_options.parallel_scan_min_rows_per_scanner |
710 | 18.4E | : 0; |
711 | 113k | } |
712 | | |
713 | 3.22k | void set_be_exec_version(int32_t version) noexcept { _query_options.be_exec_version = version; } |
714 | | |
715 | | using LocalState = doris::PipelineXLocalStateBase; |
716 | | using SinkLocalState = doris::PipelineXSinkLocalStateBase; |
717 | | // get result can return an error message, and we will only call it during the prepare. |
718 | | void emplace_local_state(int id, std::unique_ptr<LocalState> state); |
719 | | |
720 | | LocalState* get_local_state(int id); |
721 | | Result<LocalState*> get_local_state_result(int id); |
722 | | |
723 | | void emplace_sink_local_state(int id, std::unique_ptr<SinkLocalState> state); |
724 | | |
725 | | SinkLocalState* get_sink_local_state(); |
726 | | |
727 | | Result<SinkLocalState*> get_sink_local_state_result(); |
728 | | |
729 | | void resize_op_id_to_local_state(int operator_size); |
730 | | |
731 | | std::vector<std::shared_ptr<RuntimeProfile>> pipeline_id_to_profile(); |
732 | | |
733 | | std::vector<std::shared_ptr<RuntimeProfile>> build_pipeline_profile(std::size_t pipeline_size); |
734 | | |
735 | 2.27M | void set_task_execution_context(std::shared_ptr<TaskExecutionContext> context) { |
736 | 2.27M | _task_execution_context_inited = true; |
737 | 2.27M | _task_execution_context = context; |
738 | 2.27M | } |
739 | | |
740 | 56.8k | bool task_execution_context_inited() const { return _task_execution_context_inited; } |
741 | | |
742 | 2.10M | std::weak_ptr<TaskExecutionContext> get_task_execution_context() { |
743 | 18.4E | CHECK(_task_execution_context_inited) |
744 | 18.4E | << "_task_execution_context_inited == false, the ctx is not inited"; |
745 | 2.10M | return _task_execution_context; |
746 | 2.10M | } |
747 | | |
748 | | Status register_producer_runtime_filter( |
749 | | const doris::TRuntimeFilterDesc& desc, |
750 | | std::shared_ptr<RuntimeFilterProducer>* producer_filter); |
751 | | |
752 | | Status register_consumer_runtime_filter( |
753 | | const doris::TRuntimeFilterDesc& desc, bool need_local_merge, int node_id, |
754 | | std::shared_ptr<RuntimeFilterConsumer>* consumer_filter); |
755 | | |
756 | | bool is_nereids() const; |
757 | | |
758 | 7.89M | bool enable_spill() const { |
759 | 7.89M | return (_query_options.__isset.enable_force_spill && _query_options.enable_force_spill) || |
760 | 7.89M | (_query_options.__isset.enable_spill && _query_options.enable_spill); |
761 | 7.89M | } |
762 | | |
763 | 15.1M | bool enable_force_spill() const { |
764 | 15.1M | return _query_options.__isset.enable_force_spill && _query_options.enable_force_spill; |
765 | 15.1M | } |
766 | | |
767 | 43.2k | int64_t spill_min_revocable_mem() const { |
768 | 43.2k | if (_query_options.__isset.min_revocable_mem) { |
769 | 43.2k | return std::max(_query_options.min_revocable_mem, (int64_t)1 << 20); |
770 | 43.2k | } |
771 | 18.4E | return 32 << 20; |
772 | 43.2k | } |
773 | | |
774 | 115 | int spill_aggregation_partition_count() const { |
775 | 115 | if (_query_options.__isset.spill_aggregation_partition_count) { |
776 | 115 | return std::min(std::max(2, _query_options.spill_aggregation_partition_count), 32); |
777 | 115 | } |
778 | 0 | return 8; |
779 | 115 | } |
780 | | |
781 | 15 | int spill_hash_join_partition_count() const { |
782 | 15 | if (_query_options.__isset.spill_hash_join_partition_count) { |
783 | 15 | return std::min(std::max(2, _query_options.spill_hash_join_partition_count), 32); |
784 | 15 | } |
785 | 0 | return 8; |
786 | 15 | } |
787 | | |
788 | 64 | int spill_repartition_max_depth() const { |
789 | 64 | if (_query_options.__isset.spill_repartition_max_depth) { |
790 | | // Clamp to a reasonable range: [1, 128] |
791 | 64 | return std::max(1, std::min(_query_options.spill_repartition_max_depth, 128)); |
792 | 64 | } |
793 | 0 | return 8; |
794 | 64 | } |
795 | | |
796 | 289k | int64_t spill_buffer_size_bytes() const { |
797 | | // clamp to [1MB, 256MB] |
798 | 289k | constexpr int64_t kMin = 1LL * 1024 * 1024; |
799 | 289k | constexpr int64_t kMax = 256LL * 1024 * 1024; |
800 | 289k | if (_query_options.__isset.spill_buffer_size_bytes) { |
801 | 289k | int64_t v = _query_options.spill_buffer_size_bytes; |
802 | 289k | if (v < kMin) return kMin; |
803 | 289k | if (v > kMax) return kMax; |
804 | 289k | return v; |
805 | 289k | } |
806 | 18.4E | return 8LL * 1024 * 1024; |
807 | 289k | } |
808 | | |
809 | | // Per-sink memory limits: after spill is triggered, the sink proactively |
810 | | // spills when its revocable memory exceeds this threshold. |
811 | | // Clamped to [1MB, 4GB], default 64MB. |
812 | 2 | int64_t spill_join_build_sink_mem_limit_bytes() const { |
813 | 2 | constexpr int64_t kMin = 1LL * 1024 * 1024; |
814 | 2 | constexpr int64_t kMax = 4LL * 1024 * 1024 * 1024; |
815 | 2 | constexpr int64_t kDefault = 64LL * 1024 * 1024; |
816 | 2 | if (_query_options.__isset.spill_join_build_sink_mem_limit_bytes) { |
817 | 2 | int64_t v = _query_options.spill_join_build_sink_mem_limit_bytes; |
818 | 2 | return std::min(std::max(v, kMin), kMax); |
819 | 2 | } |
820 | 0 | return kDefault; |
821 | 2 | } |
822 | | |
823 | 232 | int64_t spill_aggregation_sink_mem_limit_bytes() const { |
824 | 232 | constexpr int64_t kMin = 1LL * 1024 * 1024; |
825 | 232 | constexpr int64_t kMax = 4LL * 1024 * 1024 * 1024; |
826 | 232 | constexpr int64_t kDefault = 64LL * 1024 * 1024; |
827 | 232 | if (_query_options.__isset.spill_aggregation_sink_mem_limit_bytes) { |
828 | 232 | int64_t v = _query_options.spill_aggregation_sink_mem_limit_bytes; |
829 | 232 | return std::min(std::max(v, kMin), kMax); |
830 | 232 | } |
831 | 0 | return kDefault; |
832 | 232 | } |
833 | | |
834 | 42 | int64_t spill_sort_sink_mem_limit_bytes() const { |
835 | 42 | constexpr int64_t kMin = 1LL * 1024 * 1024; |
836 | 42 | constexpr int64_t kMax = 4LL * 1024 * 1024 * 1024; |
837 | 42 | constexpr int64_t kDefault = 64LL * 1024 * 1024; |
838 | 42 | if (_query_options.__isset.spill_sort_sink_mem_limit_bytes) { |
839 | 42 | int64_t v = _query_options.spill_sort_sink_mem_limit_bytes; |
840 | 42 | return std::min(std::max(v, kMin), kMax); |
841 | 42 | } |
842 | 0 | return kDefault; |
843 | 42 | } |
844 | | |
845 | 7.51k | int64_t spill_analytic_sink_mem_limit_bytes() const { |
846 | 7.51k | constexpr int64_t kMin = 1LL * 1024 * 1024; |
847 | 7.51k | constexpr int64_t kMax = 4LL * 1024 * 1024 * 1024; |
848 | 7.51k | constexpr int64_t kDefault = 64LL * 1024 * 1024; |
849 | 7.51k | if (_query_options.__isset.spill_analytic_sink_mem_limit_bytes) { |
850 | 7.51k | int64_t v = _query_options.spill_analytic_sink_mem_limit_bytes; |
851 | 7.51k | return std::min(std::max(v, kMin), kMax); |
852 | 7.51k | } |
853 | 0 | return kDefault; |
854 | 7.51k | } |
855 | | |
856 | 17 | int64_t spill_sort_merge_mem_limit_bytes() const { |
857 | 17 | constexpr int64_t kMin = 1LL * 1024 * 1024; |
858 | 17 | constexpr int64_t kMax = 4LL * 1024 * 1024 * 1024; |
859 | 17 | constexpr int64_t kDefault = 64LL * 1024 * 1024; |
860 | 17 | if (_query_options.__isset.spill_sort_merge_mem_limit_bytes) { |
861 | 17 | int64_t v = _query_options.spill_sort_merge_mem_limit_bytes; |
862 | 17 | return std::min(std::max(v, kMin), kMax); |
863 | 17 | } |
864 | 0 | return kDefault; |
865 | 17 | } |
866 | | |
867 | 890 | int64_t low_memory_mode_buffer_limit() const { |
868 | 890 | if (_query_options.__isset.low_memory_mode_buffer_limit) { |
869 | 890 | return std::max(_query_options.low_memory_mode_buffer_limit, (int64_t)1); |
870 | 890 | } |
871 | 0 | return 32L * 1024 * 1024; |
872 | 890 | } |
873 | | |
874 | 0 | int spill_revocable_memory_high_watermark_percent() const { |
875 | 0 | if (_query_options.__isset.revocable_memory_high_watermark_percent) { |
876 | 0 | return _query_options.revocable_memory_high_watermark_percent; |
877 | 0 | } |
878 | 0 | return -1; |
879 | 0 | } |
880 | | |
881 | 193k | MOCK_FUNCTION bool enable_shared_exchange_sink_buffer() const { |
882 | 193k | return _query_options.__isset.enable_shared_exchange_sink_buffer && |
883 | 193k | _query_options.enable_shared_exchange_sink_buffer; |
884 | 193k | } |
885 | | |
886 | 11.0M | size_t minimum_operator_memory_required_bytes() const { |
887 | 11.0M | if (_query_options.__isset.minimum_operator_memory_required_kb) { |
888 | 11.0M | return _query_options.minimum_operator_memory_required_kb * 1024; |
889 | 18.4E | } else { |
890 | | // refer other database |
891 | 18.4E | return 4 * 1024 * 1024; |
892 | 18.4E | } |
893 | 11.0M | } |
894 | | |
895 | 260k | MOCK_FUNCTION bool enable_use_hybrid_sort() const { |
896 | 260k | return _query_options.__isset.enable_use_hybrid_sort && |
897 | 260k | _query_options.enable_use_hybrid_sort; |
898 | 260k | } |
899 | | |
900 | 1.90M | void set_max_operator_id(int max_operator_id) { _max_operator_id = max_operator_id; } |
901 | | |
902 | 290 | int max_operator_id() const { return _max_operator_id; } |
903 | | |
904 | 1.83M | void set_task_id(int id) { _task_id = id; } |
905 | | |
906 | 1.00k | int task_id() const { return _task_id; } |
907 | | |
908 | 1.83M | void set_task_num(int task_num) { _task_num = task_num; } |
909 | | |
910 | 61.2k | int task_num() const { return _task_num; } |
911 | | |
912 | 361k | int profile_level() const { return _profile_level; } |
913 | | |
914 | 21.4k | std::shared_ptr<IdFileMap>& get_id_file_map() { return _id_file_map; } |
915 | | |
916 | | void set_id_file_map(); |
917 | 953k | VectorSearchUserParams get_vector_search_params() const { |
918 | 953k | VectorSearchUserParams params; |
919 | 953k | params.hnsw_ef_search = _query_options.hnsw_ef_search; |
920 | 953k | params.hnsw_check_relative_distance = _query_options.hnsw_check_relative_distance; |
921 | 953k | params.hnsw_bounded_queue = _query_options.hnsw_bounded_queue; |
922 | 953k | params.ivf_nprobe = _query_options.ivf_nprobe; |
923 | 953k | params.ann_index_candidate_rows_threshold = |
924 | 953k | _query_options.__isset.ann_index_candidate_rows_threshold |
925 | 953k | ? _query_options.ann_index_candidate_rows_threshold |
926 | 953k | : 0; |
927 | 953k | params.ann_index_candidate_rows_percent_threshold = |
928 | 953k | _query_options.__isset.ann_index_candidate_rows_percent_threshold |
929 | 953k | ? _query_options.ann_index_candidate_rows_percent_threshold |
930 | 953k | : 0.3; |
931 | 953k | return params; |
932 | 953k | } |
933 | | |
934 | 137 | bool runtime_filter_wait_infinitely() const { |
935 | 137 | return _query_options.__isset.runtime_filter_wait_infinitely && |
936 | 137 | _query_options.runtime_filter_wait_infinitely; |
937 | 137 | } |
938 | | |
939 | | const std::set<int>& get_deregister_runtime_filter() const; |
940 | | |
941 | | void merge_register_runtime_filter(const std::set<int>& runtime_filter_ids); |
942 | | |
943 | | private: |
944 | | friend class ExternalFileReportReservation; |
945 | | |
946 | | void release_external_file_report_reservation(size_t reserved_bytes); |
947 | | |
948 | | Status create_error_log_file(); |
949 | | |
950 | | static const int DEFAULT_BATCH_SIZE = 4062; |
951 | | |
952 | | std::shared_ptr<MemTrackerLimiter> _query_mem_tracker = nullptr; |
953 | | |
954 | | // Could not find a better way to record if the weak ptr is inited, use a bool to record |
955 | | // it. In some unit test cases, the runtime state's task ctx is not inited, then the test |
956 | | // hang, it is very hard to debug. |
957 | | bool _task_execution_context_inited = false; |
958 | | // Hold execution context for other threads |
959 | | std::weak_ptr<TaskExecutionContext> _task_execution_context; |
960 | | |
961 | | // put runtime state before _obj_pool, so that it will be deconstructed after |
962 | | // _obj_pool. Because some of object in _obj_pool will use profile when deconstructing. |
963 | | RuntimeProfile _profile; |
964 | | RuntimeProfile _load_channel_profile; |
965 | | // Why 2? |
966 | | // During cluster upgrade, fe will not pass profile_level to be, so we need to set it to 2 |
967 | | // to make sure user can see all profile counters like before. |
968 | | int _profile_level = 2; |
969 | | |
970 | | const DescriptorTbl* _desc_tbl = nullptr; |
971 | | std::shared_ptr<ObjectPool> _obj_pool; |
972 | | |
973 | | // owned by PipelineFragmentContext |
974 | | RuntimeFilterMgr* _runtime_filter_mgr = nullptr; |
975 | | |
976 | | // Lock protecting _error_log and _unreported_error_idx |
977 | | std::mutex _error_log_lock; |
978 | | |
979 | | // Logs error messages. |
980 | | std::vector<std::string> _error_log; |
981 | | |
982 | | // _error_log[_unreported_error_idx+] has been not reported to the coordinator. |
983 | | int _unreported_error_idx; |
984 | | |
985 | | //Query-global timestamp_ms |
986 | | int64_t _timestamp_ms; |
987 | | int32_t _nano_seconds; |
988 | | std::string _timezone; |
989 | | cctz::time_zone _timezone_obj; |
990 | | std::string _lc_time_names; |
991 | | |
992 | | TUniqueId _query_id; |
993 | | // fragment id for each TPipelineFragmentParams |
994 | | int32_t _fragment_id; |
995 | | TUniqueId _fragment_instance_id; |
996 | | TQueryOptions _query_options; |
997 | | ExecEnv* _exec_env = nullptr; |
998 | | |
999 | | AtomicStatus _exec_status; |
1000 | | |
1001 | | int _per_fragment_instance_idx; |
1002 | | int _num_per_fragment_instances = 0; |
1003 | | int _load_stream_per_node = 0; |
1004 | | int _total_load_streams = 0; |
1005 | | int _num_local_sink = 0; |
1006 | | |
1007 | | // The backend id on which this fragment instance runs |
1008 | | int64_t _backend_id = -1; |
1009 | | |
1010 | | // used as send id |
1011 | | int _be_number; |
1012 | | |
1013 | | // put here to collect files?? |
1014 | | std::vector<std::string> _output_files; |
1015 | | std::atomic<int64_t> _num_rows_load_total; // total rows read from source |
1016 | | std::atomic<int64_t> _num_rows_load_filtered; // unqualified rows |
1017 | | std::atomic<int64_t> _num_rows_load_unselected; // rows filtered by predicates |
1018 | | std::atomic<int64_t> _num_rows_filtered_in_strict_mode_partial_update; |
1019 | | std::atomic<int64_t> _num_print_error_rows; |
1020 | | |
1021 | | std::atomic<int64_t> _num_bytes_load_total; // total bytes read from source |
1022 | | std::atomic<int64_t> _num_finished_scan_range; |
1023 | | |
1024 | | std::vector<std::string> _export_output_files; |
1025 | | std::string _import_label; |
1026 | | std::string _db_name; |
1027 | | std::string _load_dir; |
1028 | | int64_t _load_job_id; |
1029 | | int64_t _wal_id = -1; |
1030 | | size_t _content_length = 0; |
1031 | | |
1032 | | // mini load |
1033 | | std::string _error_log_file_path; |
1034 | | std::unique_ptr<std::ofstream> _error_log_file; // error file path, absolute path |
1035 | | std::string _first_error_msg = ""; |
1036 | | mutable std::mutex _tablet_infos_mutex; |
1037 | | std::vector<TTabletCommitInfo> _tablet_commit_infos; |
1038 | | std::vector<TErrorTabletInfo> _error_tablet_infos; |
1039 | | int _max_operator_id = 0; |
1040 | | int _task_id = -1; |
1041 | | int _task_num = 0; |
1042 | | |
1043 | | mutable std::mutex _hive_partition_updates_mutex; |
1044 | | std::vector<THivePartitionUpdate> _hive_partition_updates; |
1045 | | |
1046 | | mutable std::mutex _iceberg_commit_datas_mutex; |
1047 | | std::vector<TIcebergCommitData> _iceberg_commit_datas; |
1048 | | std::shared_ptr<ExternalFileReportState> _external_file_report_state = |
1049 | | std::make_shared<ExternalFileReportState>(); |
1050 | | |
1051 | | mutable std::mutex _mc_commit_datas_mutex; |
1052 | | std::vector<TMCCommitData> _mc_commit_datas; |
1053 | | |
1054 | | mutable std::mutex _paimon_commit_messages_mutex; |
1055 | | std::vector<TPaimonCommitMessage> _paimon_commit_messages; |
1056 | | |
1057 | | std::vector<std::unique_ptr<doris::PipelineXLocalStateBase>> _op_id_to_local_state; |
1058 | | |
1059 | | std::unique_ptr<doris::PipelineXSinkLocalStateBase> _sink_local_state; |
1060 | | |
1061 | | QueryContext* _query_ctx = nullptr; |
1062 | | |
1063 | | // true if max_filter_ratio is 0 |
1064 | | bool _load_zero_tolerance = false; |
1065 | | |
1066 | | // only to lock _pipeline_id_to_profile |
1067 | | std::shared_mutex _pipeline_profile_lock; |
1068 | | std::vector<std::shared_ptr<RuntimeProfile>> _pipeline_id_to_profile; |
1069 | | |
1070 | | // save error log to s3 |
1071 | | std::shared_ptr<io::S3FileSystem> _s3_error_fs; |
1072 | | // error file path on s3, ${bucket}/${prefix}/error_log/${label}_${fragment_instance_id} |
1073 | | std::string _s3_error_log_file_path; |
1074 | | // Protects the load error log stream, paths, and first error message. |
1075 | | mutable std::mutex _load_error_log_lock; |
1076 | | // Serializes S3 upload and presigned URL publication. |
1077 | | std::mutex _s3_error_log_file_lock; |
1078 | | |
1079 | | // used for encoding the global lazy materialize |
1080 | | std::shared_ptr<IdFileMap> _id_file_map = nullptr; |
1081 | | |
1082 | | std::set<int> _registered_runtime_filter_ids; |
1083 | | }; |
1084 | | |
1085 | | #define RETURN_IF_CANCELLED(state) \ |
1086 | 1.53M | do { \ |
1087 | 1.53M | if (UNLIKELY((state)->is_cancelled())) { \ |
1088 | 27 | return (state)->cancel_reason(); \ |
1089 | 27 | } \ |
1090 | 1.53M | } while (false) |
1091 | | |
1092 | | } // namespace doris |