Coverage Report

Created: 2026-08-06 18:45

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