Coverage Report

Created: 2026-05-13 03:56

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/runtime/workload_management/resource_context.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
18
#include "runtime/workload_management/resource_context.h"
19
20
#include <gen_cpp/data.pb.h>
21
#include <glog/logging.h>
22
23
#include "runtime/workload_management/query_task_controller.h"
24
#include "util/time.h"
25
26
namespace doris {
27
28
2
void ResourceContext::to_thrift_query_statistics(TQueryStatistics* statistics) const {
29
2
    DCHECK(statistics != nullptr);
30
2
    statistics->__set_scan_rows(io_context()->scan_rows());
31
2
    statistics->__set_scan_bytes(io_context()->scan_bytes());
32
2
    statistics->__set_cpu_ms(cpu_context()->cpu_cost_ms() / NANOS_PER_MILLIS);
33
2
    statistics->__set_returned_rows(io_context()->returned_rows());
34
2
    statistics->__set_process_rows(io_context()->process_rows());
35
2
    statistics->__set_max_peak_memory_bytes(memory_context()->max_peak_memory_bytes());
36
2
    statistics->__set_current_used_memory_bytes(memory_context()->current_memory_bytes());
37
2
    statistics->__set_shuffle_send_bytes(io_context()->shuffle_send_bytes());
38
2
    statistics->__set_shuffle_send_rows(io_context()->shuffle_send_rows());
39
2
    statistics->__set_scan_bytes_from_remote_storage(
40
2
            io_context()->scan_bytes_from_remote_storage());
41
2
    statistics->__set_scan_bytes_from_local_storage(io_context()->scan_bytes_from_local_storage());
42
2
    statistics->__set_bytes_write_into_cache(io_context()->bytes_write_into_cache());
43
44
2
    if (workload_group() != nullptr) {
45
0
        statistics->__set_workload_group_id(workload_group()->id());
46
2
    } else {
47
2
        statistics->__set_workload_group_id(-1);
48
2
    }
49
50
2
    statistics->__set_spill_write_bytes_to_local_storage(
51
2
            io_context_->spill_write_bytes_to_local_storage());
52
2
    statistics->__set_spill_read_bytes_from_local_storage(
53
2
            io_context_->spill_read_bytes_from_local_storage());
54
55
2
    if (auto* query_task_controller = dynamic_cast<QueryTaskController*>(task_controller())) {
56
        // Fill query task-level progress directly from task controller.
57
2
        statistics->__set_total_tasks_num(query_task_controller->get_total_task_num());
58
2
        statistics->__set_finished_tasks_num(query_task_controller->get_finished_task_num());
59
2
    }
60
2
}
61
62
} // namespace doris