Coverage Report

Created: 2025-12-26 14:37

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