Coverage Report

Created: 2026-03-06 19:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/be/src/runtime/runtime_state.cpp
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.cpp
19
// and modified by Doris
20
21
#include "runtime/runtime_state.h"
22
23
#include <fmt/format.h>
24
#include <gen_cpp/PaloInternalService_types.h>
25
#include <gen_cpp/Types_types.h>
26
#include <glog/logging.h>
27
28
#include <fstream>
29
#include <memory>
30
#include <string>
31
32
#include "cloud/cloud_storage_engine.h"
33
#include "cloud/config.h"
34
#include "common/config.h"
35
#include "common/logging.h"
36
#include "common/object_pool.h"
37
#include "common/status.h"
38
#include "io/fs/s3_file_system.h"
39
#include "olap/id_manager.h"
40
#include "olap/storage_engine.h"
41
#include "pipeline/exec/operator.h"
42
#include "pipeline/pipeline_task.h"
43
#include "runtime/exec_env.h"
44
#include "runtime/fragment_mgr.h"
45
#include "runtime/load_path_mgr.h"
46
#include "runtime/memory/mem_tracker_limiter.h"
47
#include "runtime/query_context.h"
48
#include "runtime/thread_context.h"
49
#include "runtime_filter/runtime_filter_mgr.h"
50
#include "util/timezone_utils.h"
51
#include "util/uid_util.h"
52
#include "vec/runtime/vdatetime_value.h"
53
54
namespace doris {
55
#include "common/compile_check_begin.h"
56
using namespace ErrorCode;
57
58
RuntimeState::RuntimeState(const TPlanFragmentExecParams& fragment_exec_params,
59
                           const TQueryOptions& query_options, const TQueryGlobals& query_globals,
60
                           ExecEnv* exec_env, QueryContext* ctx,
61
                           const std::shared_ptr<MemTrackerLimiter>& query_mem_tracker)
62
0
        : _profile("Fragment " + print_id(fragment_exec_params.fragment_instance_id)),
63
0
          _load_channel_profile("<unnamed>"),
64
0
          _obj_pool(new ObjectPool()),
65
0
          _unreported_error_idx(0),
66
0
          _query_id(fragment_exec_params.query_id),
67
0
          _per_fragment_instance_idx(0),
68
0
          _num_rows_load_total(0),
69
0
          _num_rows_load_filtered(0),
70
0
          _num_rows_load_unselected(0),
71
0
          _num_print_error_rows(0),
72
0
          _num_bytes_load_total(0),
73
0
          _num_finished_scan_range(0),
74
0
          _query_ctx(ctx) {
75
0
    Status status =
76
0
            init(fragment_exec_params.fragment_instance_id, query_options, query_globals, exec_env);
77
0
    DCHECK(status.ok());
78
0
    _query_mem_tracker = query_mem_tracker;
79
0
    DCHECK(_query_mem_tracker != nullptr);
80
0
}
81
82
RuntimeState::RuntimeState(const TUniqueId& instance_id, const TUniqueId& query_id,
83
                           int32_t fragment_id, const TQueryOptions& query_options,
84
                           const TQueryGlobals& query_globals, ExecEnv* exec_env, QueryContext* ctx)
85
49
        : _profile("Fragment " + print_id(instance_id)),
86
49
          _load_channel_profile("<unnamed>"),
87
49
          _obj_pool(new ObjectPool()),
88
49
          _unreported_error_idx(0),
89
49
          _query_id(query_id),
90
49
          _fragment_id(fragment_id),
91
49
          _per_fragment_instance_idx(0),
92
49
          _num_rows_load_total(0),
93
49
          _num_rows_load_filtered(0),
94
49
          _num_rows_load_unselected(0),
95
49
          _num_rows_filtered_in_strict_mode_partial_update(0),
96
49
          _num_print_error_rows(0),
97
49
          _num_bytes_load_total(0),
98
49
          _num_finished_scan_range(0),
99
49
          _query_ctx(ctx) {
100
49
    [[maybe_unused]] auto status = init(instance_id, query_options, query_globals, exec_env);
101
49
    DCHECK(status.ok());
102
49
    _query_mem_tracker = ctx->query_mem_tracker();
103
49
}
104
105
RuntimeState::RuntimeState(const TUniqueId& query_id, int32_t fragment_id,
106
                           const TQueryOptions& query_options, const TQueryGlobals& query_globals,
107
                           ExecEnv* exec_env, QueryContext* ctx)
108
104
        : _profile("PipelineX  " + std::to_string(fragment_id)),
109
104
          _load_channel_profile("<unnamed>"),
110
104
          _obj_pool(new ObjectPool()),
111
104
          _unreported_error_idx(0),
112
104
          _query_id(query_id),
113
104
          _fragment_id(fragment_id),
114
104
          _per_fragment_instance_idx(0),
115
104
          _num_rows_load_total(0),
116
104
          _num_rows_load_filtered(0),
117
104
          _num_rows_load_unselected(0),
118
104
          _num_rows_filtered_in_strict_mode_partial_update(0),
119
104
          _num_print_error_rows(0),
120
104
          _num_bytes_load_total(0),
121
104
          _num_finished_scan_range(0),
122
104
          _query_ctx(ctx) {
123
    // TODO: do we really need instance id?
124
104
    Status status = init(TUniqueId(), query_options, query_globals, exec_env);
125
104
    DCHECK(status.ok());
126
104
    _query_mem_tracker = ctx->query_mem_tracker();
127
104
}
128
129
RuntimeState::RuntimeState(const TUniqueId& query_id, int32_t fragment_id,
130
                           const TQueryOptions& query_options, const TQueryGlobals& query_globals,
131
                           ExecEnv* exec_env,
132
                           const std::shared_ptr<MemTrackerLimiter>& query_mem_tracker)
133
0
        : _profile("PipelineX  " + std::to_string(fragment_id)),
134
0
          _load_channel_profile("<unnamed>"),
135
0
          _obj_pool(new ObjectPool()),
136
0
          _unreported_error_idx(0),
137
0
          _query_id(query_id),
138
0
          _fragment_id(fragment_id),
139
0
          _per_fragment_instance_idx(0),
140
0
          _num_rows_load_total(0),
141
0
          _num_rows_load_filtered(0),
142
0
          _num_rows_load_unselected(0),
143
0
          _num_rows_filtered_in_strict_mode_partial_update(0),
144
0
          _num_print_error_rows(0),
145
0
          _num_bytes_load_total(0),
146
0
          _num_finished_scan_range(0) {
147
0
    Status status = init(TUniqueId(), query_options, query_globals, exec_env);
148
0
    DCHECK(status.ok());
149
0
    _query_mem_tracker = query_mem_tracker;
150
0
    DCHECK(_query_mem_tracker != nullptr);
151
0
}
152
153
RuntimeState::RuntimeState(const TQueryOptions& query_options, const TQueryGlobals& query_globals)
154
49.2k
        : _profile("<unnamed>"),
155
49.2k
          _load_channel_profile("<unnamed>"),
156
49.2k
          _obj_pool(new ObjectPool()),
157
49.2k
          _unreported_error_idx(0),
158
49.2k
          _per_fragment_instance_idx(0) {
159
49.2k
    Status status = init(TUniqueId(), query_options, query_globals, nullptr);
160
49.2k
    _exec_env = ExecEnv::GetInstance();
161
49.2k
    init_mem_trackers("<unnamed>");
162
49.2k
    DCHECK(status.ok());
163
49.2k
}
164
165
RuntimeState::RuntimeState()
166
130k
        : _profile("<unnamed>"),
167
130k
          _load_channel_profile("<unnamed>"),
168
130k
          _obj_pool(new ObjectPool()),
169
130k
          _unreported_error_idx(0),
170
130k
          _per_fragment_instance_idx(0) {
171
130k
    _query_options.batch_size = DEFAULT_BATCH_SIZE;
172
130k
    _query_options.be_exec_version = BeExecVersionManager::get_newest_version();
173
130k
    _timezone = TimezoneUtils::default_time_zone;
174
130k
    _timestamp_ms = 0;
175
130k
    _nano_seconds = 0;
176
130k
    TimezoneUtils::find_cctz_time_zone(_timezone, _timezone_obj);
177
130k
    _exec_env = ExecEnv::GetInstance();
178
130k
    init_mem_trackers("<unnamed>");
179
130k
}
180
181
179k
RuntimeState::~RuntimeState() {
182
179k
    SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_query_mem_tracker);
183
    // close error log file
184
179k
    if (_error_log_file != nullptr && _error_log_file->is_open()) {
185
0
        _error_log_file->close();
186
0
    }
187
179k
    _obj_pool->clear();
188
179k
}
189
190
2
const std::set<int>& RuntimeState::get_deregister_runtime_filter() const {
191
2
    return _registered_runtime_filter_ids;
192
2
}
193
194
2
void RuntimeState::merge_register_runtime_filter(const std::set<int>& runtime_filter_ids) {
195
2
    _registered_runtime_filter_ids.insert(runtime_filter_ids.begin(), runtime_filter_ids.end());
196
2
}
197
198
Status RuntimeState::init(const TUniqueId& fragment_instance_id, const TQueryOptions& query_options,
199
49.4k
                          const TQueryGlobals& query_globals, ExecEnv* exec_env) {
200
49.4k
    _fragment_instance_id = fragment_instance_id;
201
49.4k
    _query_options = query_options;
202
49.4k
    _lc_time_names = query_globals.lc_time_names;
203
49.4k
    if (query_globals.__isset.time_zone && query_globals.__isset.nano_seconds) {
204
49.2k
        _timezone = query_globals.time_zone;
205
49.2k
        _timestamp_ms = query_globals.timestamp_ms;
206
49.2k
        _nano_seconds = query_globals.nano_seconds;
207
49.2k
    } else if (query_globals.__isset.time_zone) {
208
0
        _timezone = query_globals.time_zone;
209
0
        _timestamp_ms = query_globals.timestamp_ms;
210
0
        _nano_seconds = 0;
211
231
    } else if (!query_globals.now_string.empty()) {
212
0
        _timezone = TimezoneUtils::default_time_zone;
213
0
        VecDateTimeValue dt;
214
0
        dt.from_date_str(query_globals.now_string.c_str(), query_globals.now_string.size());
215
0
        int64_t timestamp;
216
0
        dt.unix_timestamp(&timestamp, _timezone);
217
0
        _timestamp_ms = timestamp * 1000;
218
0
        _nano_seconds = 0;
219
231
    } else {
220
        //Unit test may set into here
221
231
        _timezone = TimezoneUtils::default_time_zone;
222
231
        _timestamp_ms = 0;
223
231
        _nano_seconds = 0;
224
231
    }
225
49.4k
    TimezoneUtils::find_cctz_time_zone(_timezone, _timezone_obj);
226
227
49.4k
    if (query_globals.__isset.load_zero_tolerance) {
228
49.4k
        _load_zero_tolerance = query_globals.load_zero_tolerance;
229
49.4k
    }
230
231
49.4k
    _exec_env = exec_env;
232
233
49.4k
    if (_query_options.max_errors <= 0) {
234
        // TODO: fix linker error and uncomment this
235
        //_query_options.max_errors = config::max_errors;
236
49.4k
        _query_options.max_errors = 100;
237
49.4k
    }
238
239
49.4k
    if (_query_options.batch_size <= 0) {
240
49.3k
        _query_options.batch_size = DEFAULT_BATCH_SIZE;
241
49.3k
    }
242
243
49.4k
    _db_name = "insert_stmt";
244
49.4k
    _import_label = print_id(fragment_instance_id);
245
246
49.4k
    _profile_level = query_options.__isset.profile_level ? query_options.profile_level : 2;
247
248
49.4k
    return Status::OK();
249
49.4k
}
250
251
0
std::weak_ptr<QueryContext> RuntimeState::get_query_ctx_weak() {
252
0
    return _exec_env->fragment_mgr()->get_query_ctx(_query_ctx->query_id());
253
0
}
254
255
179k
void RuntimeState::init_mem_trackers(const std::string& name, const TUniqueId& id) {
256
179k
    _query_mem_tracker = MemTrackerLimiter::create_shared(
257
179k
            MemTrackerLimiter::Type::OTHER, fmt::format("{}#Id={}", name, print_id(id)));
258
179k
}
259
260
172
std::shared_ptr<MemTrackerLimiter> RuntimeState::query_mem_tracker() const {
261
172
    CHECK(_query_mem_tracker != nullptr);
262
172
    return _query_mem_tracker;
263
172
}
264
265
11
WorkloadGroupPtr RuntimeState::workload_group() {
266
11
    return _query_ctx->workload_group();
267
11
}
268
269
0
bool RuntimeState::log_error(const std::string& error) {
270
0
    std::lock_guard<std::mutex> l(_error_log_lock);
271
272
0
    if (_error_log.size() < _query_options.max_errors) {
273
0
        _error_log.push_back(error);
274
0
        return true;
275
0
    }
276
277
0
    return false;
278
0
}
279
280
0
void RuntimeState::get_unreported_errors(std::vector<std::string>* new_errors) {
281
0
    std::lock_guard<std::mutex> l(_error_log_lock);
282
283
0
    if (_unreported_error_idx < _error_log.size()) {
284
0
        new_errors->assign(_error_log.begin() + _unreported_error_idx, _error_log.end());
285
0
        _unreported_error_idx = (int)_error_log.size();
286
0
    }
287
0
}
288
289
1.09M
bool RuntimeState::is_cancelled() const {
290
    // Maybe we should just return _is_cancelled.load()
291
1.09M
    return !_exec_status.ok() || (_query_ctx && _query_ctx->is_cancelled());
292
1.09M
}
293
294
0
Status RuntimeState::cancel_reason() const {
295
0
    if (!_exec_status.ok()) {
296
0
        return _exec_status.status();
297
0
    }
298
299
0
    if (_query_ctx) {
300
0
        return _query_ctx->exec_status();
301
0
    }
302
303
0
    return Status::Cancelled("Query cancelled");
304
0
}
305
306
const int64_t MAX_ERROR_NUM = 50;
307
308
0
Status RuntimeState::create_error_log_file() {
309
0
    if (config::save_load_error_log_to_s3 && config::is_cloud_mode()) {
310
0
        _s3_error_fs = std::dynamic_pointer_cast<io::S3FileSystem>(
311
0
                ExecEnv::GetInstance()->storage_engine().to_cloud().latest_fs());
312
0
        if (_s3_error_fs) {
313
0
            std::stringstream ss;
314
            // https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html
315
            // shorten the path as much as possible to prevent the length of the presigned URL from
316
            // exceeding the MySQL error packet size limit
317
0
            ss << "error_log/" << std::hex << _fragment_instance_id.lo;
318
0
            _s3_error_log_file_path = ss.str();
319
0
        }
320
0
    }
321
322
0
    static_cast<void>(_exec_env->load_path_mgr()->get_load_error_file_name(
323
0
            _db_name, _import_label, _fragment_instance_id, &_error_log_file_path));
324
0
    std::string error_log_absolute_path =
325
0
            _exec_env->load_path_mgr()->get_load_error_absolute_path(_error_log_file_path);
326
0
    _error_log_file = std::make_unique<std::ofstream>(error_log_absolute_path, std::ifstream::out);
327
0
    if (!_error_log_file->is_open()) {
328
0
        std::stringstream error_msg;
329
0
        error_msg << "Fail to open error file: [" << _error_log_file_path << "].";
330
0
        LOG(WARNING) << error_msg.str();
331
0
        return Status::InternalError(error_msg.str());
332
0
    }
333
0
    LOG(INFO) << "create error log file: " << _error_log_file_path
334
0
              << ", query id: " << print_id(_query_id)
335
0
              << ", fragment instance id: " << print_id(_fragment_instance_id);
336
337
0
    return Status::OK();
338
0
}
339
340
Status RuntimeState::append_error_msg_to_file(std::function<std::string()> line,
341
0
                                              std::function<std::string()> error_msg) {
342
0
    if (query_type() != TQueryType::LOAD) {
343
0
        return Status::OK();
344
0
    }
345
    // If file haven't been opened, open it here
346
0
    if (_error_log_file == nullptr) {
347
0
        Status status = create_error_log_file();
348
0
        if (!status.ok()) {
349
0
            LOG(WARNING) << "Create error file log failed. because: " << status;
350
0
            if (_error_log_file != nullptr) {
351
0
                _error_log_file->close();
352
0
            }
353
0
            return status;
354
0
        }
355
        // record the first error message if the file is just created
356
0
        _first_error_msg = error_msg() + ". Src line: " + line();
357
0
        LOG(INFO) << "The first error message: " << _first_error_msg;
358
0
    }
359
    // If num of printed error row exceeds the limit, don't add error messages to error log file any more
360
0
    if (_num_print_error_rows.fetch_add(1, std::memory_order_relaxed) > MAX_ERROR_NUM) {
361
        // if _load_zero_tolerance, return Error to stop the load process immediately.
362
0
        if (_load_zero_tolerance) {
363
0
            return Status::DataQualityError(
364
0
                    "Encountered unqualified data, stop processing. Please check if the source "
365
0
                    "data matches the schema, and consider disabling strict mode or increasing "
366
0
                    "max_filter_ratio.");
367
0
        }
368
0
        return Status::OK();
369
0
    }
370
371
0
    fmt::memory_buffer out;
372
    // Note: export reason first in case src line too long and be truncated.
373
0
    fmt::format_to(out, "Reason: {}. src line [{}]; ", error_msg(), line());
374
375
0
    size_t error_row_size = out.size();
376
0
    if (error_row_size > 0) {
377
0
        if (error_row_size > config::load_error_log_limit_bytes) {
378
0
            fmt::memory_buffer limit_byte_out;
379
0
            limit_byte_out.append(out.data(), out.data() + config::load_error_log_limit_bytes);
380
0
            (*_error_log_file) << fmt::to_string(limit_byte_out) + "error log is too long"
381
0
                               << std::endl;
382
0
        } else {
383
0
            (*_error_log_file) << fmt::to_string(out) << std::endl;
384
0
        }
385
0
    }
386
387
0
    return Status::OK();
388
0
}
389
390
0
std::string RuntimeState::get_error_log_file_path() {
391
0
    DBUG_EXECUTE_IF("RuntimeState::get_error_log_file_path.block", {
392
0
        if (!_error_log_file_path.empty()) {
393
0
            std::this_thread::sleep_for(std::chrono::seconds(1));
394
0
        }
395
0
    });
396
0
    std::lock_guard<std::mutex> l(_s3_error_log_file_lock);
397
0
    if (_s3_error_fs && _error_log_file && _error_log_file->is_open()) {
398
        // close error log file
399
0
        _error_log_file->close();
400
0
        std::string error_log_absolute_path =
401
0
                _exec_env->load_path_mgr()->get_load_error_absolute_path(_error_log_file_path);
402
        // upload error log file to s3
403
0
        Status st = _s3_error_fs->upload(error_log_absolute_path, _s3_error_log_file_path);
404
0
        if (!st.ok()) {
405
            // upload failed and return local error log file path
406
0
            LOG(WARNING) << "Fail to upload error file to s3, error_log_file_path="
407
0
                         << _error_log_file_path << ", error=" << st;
408
0
            return _error_log_file_path;
409
0
        }
410
        // expiration must be less than a week (in seconds) for presigned url
411
0
        static const unsigned EXPIRATION_SECONDS = 7 * 24 * 60 * 60 - 1;
412
        // Use public or private endpoint based on configuration
413
0
        _error_log_file_path =
414
0
                _s3_error_fs->generate_presigned_url(_s3_error_log_file_path, EXPIRATION_SECONDS,
415
0
                                                     config::use_public_endpoint_for_error_log);
416
0
    }
417
0
    return _error_log_file_path;
418
0
}
419
420
72.3k
void RuntimeState::resize_op_id_to_local_state(int operator_size) {
421
72.3k
    _op_id_to_local_state.resize(-operator_size);
422
72.3k
}
423
424
void RuntimeState::emplace_local_state(
425
24.2k
        int id, std::unique_ptr<doris::pipeline::PipelineXLocalStateBase> state) {
426
24.2k
    id = -id;
427
24.2k
    DCHECK_LT(id, _op_id_to_local_state.size())
428
0
            << state->parent()->get_name() << " node id = " << state->parent()->node_id();
429
24.2k
    DCHECK(!_op_id_to_local_state[id]);
430
24.2k
    _op_id_to_local_state[id] = std::move(state);
431
24.2k
}
432
433
2.02M
doris::pipeline::PipelineXLocalStateBase* RuntimeState::get_local_state(int id) {
434
2.02M
    DCHECK_GT(_op_id_to_local_state.size(), -id);
435
2.02M
    return _op_id_to_local_state[-id].get();
436
2.02M
}
437
438
24.0k
Result<RuntimeState::LocalState*> RuntimeState::get_local_state_result(int id) {
439
24.0k
    id = -id;
440
24.0k
    if (id >= _op_id_to_local_state.size()) {
441
0
        return ResultError(Status::InternalError("get_local_state out of range size:{} , id:{}",
442
0
                                                 _op_id_to_local_state.size(), id));
443
0
    }
444
24.0k
    if (!_op_id_to_local_state[id]) {
445
0
        return ResultError(Status::InternalError("get_local_state id:{} is null", id));
446
0
    }
447
24.0k
    return _op_id_to_local_state[id].get();
448
24.0k
};
449
450
void RuntimeState::emplace_sink_local_state(
451
72.2k
        int id, std::unique_ptr<doris::pipeline::PipelineXSinkLocalStateBase> state) {
452
72.2k
    DCHECK(!_sink_local_state) << " id=" << id << " state: " << state->debug_string(0);
453
72.2k
    _sink_local_state = std::move(state);
454
72.2k
}
455
456
416k
doris::pipeline::PipelineXSinkLocalStateBase* RuntimeState::get_sink_local_state() {
457
416k
    return _sink_local_state.get();
458
416k
}
459
460
1.03M
Result<RuntimeState::SinkLocalState*> RuntimeState::get_sink_local_state_result() {
461
1.03M
    if (!_sink_local_state) {
462
0
        return ResultError(Status::InternalError("_op_id_to_sink_local_state not exist"));
463
0
    }
464
1.03M
    return _sink_local_state.get();
465
1.03M
}
466
467
0
bool RuntimeState::enable_page_cache() const {
468
0
    return !config::disable_storage_page_cache &&
469
0
           (_query_options.__isset.enable_page_cache && _query_options.enable_page_cache);
470
0
}
471
472
60
RuntimeFilterMgr* RuntimeState::global_runtime_filter_mgr() {
473
60
    return _query_ctx->runtime_filter_mgr();
474
60
}
475
476
Status RuntimeState::register_producer_runtime_filter(
477
29
        const TRuntimeFilterDesc& desc, std::shared_ptr<RuntimeFilterProducer>* producer_filter) {
478
29
    _registered_runtime_filter_ids.insert(desc.filter_id);
479
    // Producers are created by local runtime filter mgr and shared by global runtime filter manager.
480
    // When RF is published, consumers in both global and local RF mgr will be found.
481
29
    RETURN_IF_ERROR(local_runtime_filter_mgr()->register_producer_filter(_query_ctx, desc,
482
29
                                                                         producer_filter));
483
29
    RETURN_IF_ERROR(global_runtime_filter_mgr()->register_local_merger_producer_filter(
484
29
            _query_ctx, desc, *producer_filter));
485
29
    return Status::OK();
486
29
}
487
488
Status RuntimeState::register_consumer_runtime_filter(
489
        const TRuntimeFilterDesc& desc, bool need_local_merge, int node_id,
490
6
        std::shared_ptr<RuntimeFilterConsumer>* consumer_filter) {
491
6
    _registered_runtime_filter_ids.insert(desc.filter_id);
492
6
    bool need_merge = desc.has_remote_targets || need_local_merge;
493
6
    RuntimeFilterMgr* mgr = need_merge ? global_runtime_filter_mgr() : local_runtime_filter_mgr();
494
6
    return mgr->register_consumer_filter(this, desc, node_id, consumer_filter);
495
6
}
496
497
64
bool RuntimeState::is_nereids() const {
498
64
    return _query_ctx->is_nereids();
499
64
}
500
501
0
std::vector<std::shared_ptr<RuntimeProfile>> RuntimeState::pipeline_id_to_profile() {
502
0
    std::shared_lock lc(_pipeline_profile_lock);
503
0
    return _pipeline_id_to_profile;
504
0
}
505
506
std::vector<std::shared_ptr<RuntimeProfile>> RuntimeState::build_pipeline_profile(
507
0
        std::size_t pipeline_size) {
508
0
    std::unique_lock lc(_pipeline_profile_lock);
509
0
    if (!_pipeline_id_to_profile.empty()) {
510
0
        return _pipeline_id_to_profile;
511
0
    }
512
0
    _pipeline_id_to_profile.resize(pipeline_size);
513
0
    {
514
0
        size_t pip_idx = 0;
515
0
        for (auto& pipeline_profile : _pipeline_id_to_profile) {
516
0
            pipeline_profile =
517
0
                    std::make_shared<RuntimeProfile>("Pipeline : " + std::to_string(pip_idx));
518
0
            pip_idx++;
519
0
        }
520
0
    }
521
0
    return _pipeline_id_to_profile;
522
0
}
523
524
655k
bool RuntimeState::low_memory_mode() const {
525
655k
#ifdef BE_TEST
526
655k
    if (!_query_ctx) {
527
0
        return false;
528
0
    }
529
655k
#endif
530
655k
    return _query_ctx->low_memory_mode();
531
655k
}
532
533
0
void RuntimeState::set_id_file_map() {
534
0
    _id_file_map = _exec_env->get_id_manager()->add_id_file_map(_query_id, execution_timeout());
535
0
}
536
#include "common/compile_check_end.h"
537
} // end namespace doris