Coverage Report

Created: 2025-10-22 22:41

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