Coverage Report

Created: 2026-03-17 15:13

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/query_context.h"
24
#include "runtime/workload_management/query_task_controller.h"
25
#include "util/time.h"
26
27
namespace doris {
28
#include "common/compile_check_begin.h"
29
30
0
void ResourceContext::to_thrift_query_statistics(TQueryStatistics* statistics) const {
31
0
    DCHECK(statistics != nullptr);
32
0
    statistics->__set_scan_rows(io_context()->scan_rows());
33
0
    statistics->__set_scan_bytes(io_context()->scan_bytes());
34
0
    statistics->__set_cpu_ms(cpu_context()->cpu_cost_ms() / NANOS_PER_MILLIS);
35
0
    statistics->__set_returned_rows(io_context()->returned_rows());
36
0
    statistics->__set_max_peak_memory_bytes(memory_context()->max_peak_memory_bytes());
37
0
    statistics->__set_current_used_memory_bytes(memory_context()->current_memory_bytes());
38
0
    statistics->__set_shuffle_send_bytes(io_context()->shuffle_send_bytes());
39
0
    statistics->__set_shuffle_send_rows(io_context()->shuffle_send_rows());
40
0
    statistics->__set_scan_bytes_from_remote_storage(
41
0
            io_context()->scan_bytes_from_remote_storage());
42
0
    statistics->__set_scan_bytes_from_local_storage(io_context()->scan_bytes_from_local_storage());
43
0
    statistics->__set_bytes_write_into_cache(io_context()->bytes_write_into_cache());
44
45
0
    if (workload_group() != nullptr) {
46
0
        statistics->__set_workload_group_id(workload_group()->id());
47
0
    } else {
48
0
        statistics->__set_workload_group_id(-1);
49
0
    }
50
51
0
    statistics->__set_spill_write_bytes_to_local_storage(
52
0
            io_context_->spill_write_bytes_to_local_storage());
53
0
    statistics->__set_spill_read_bytes_from_local_storage(
54
0
            io_context_->spill_read_bytes_from_local_storage());
55
56
0
    if (auto* query_task_controller = dynamic_cast<QueryTaskController*>(task_controller())) {
57
0
        if (auto query_ctx = query_task_controller->get_query_ctx()) {
58
0
            int total = 0;
59
0
            int finished = 0;
60
0
            query_ctx->get_instance_counts(&total, &finished);
61
0
            statistics->__set_total_instances_num(total);
62
0
            statistics->__set_finished_instances_num(finished);
63
0
        }
64
0
    }
65
0
}
66
67
#include "common/compile_check_end.h"
68
} // namespace doris