/root/doris/be/src/runtime/query_statistics.cpp
Line | Count | Source (jump to first uncovered line) |
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/query_statistics.h" |
19 | | |
20 | | #include <gen_cpp/data.pb.h> |
21 | | #include <glog/logging.h> |
22 | | |
23 | | #include <memory> |
24 | | |
25 | | #include "util/time.h" |
26 | | |
27 | | namespace doris { |
28 | | |
29 | 0 | void QueryStatistics::merge(const QueryStatistics& other) { |
30 | 0 | scan_rows += other.scan_rows; |
31 | 0 | scan_bytes += other.scan_bytes; |
32 | 0 | cpu_nanos += other.cpu_nanos; |
33 | 0 | shuffle_send_bytes += other.shuffle_send_bytes; |
34 | 0 | shuffle_send_rows += other.shuffle_send_rows; |
35 | 0 | _scan_bytes_from_local_storage += other._scan_bytes_from_local_storage; |
36 | 0 | _scan_bytes_from_remote_storage += other._scan_bytes_from_remote_storage; |
37 | |
|
38 | 0 | int64_t other_peak_mem = other.max_peak_memory_bytes; |
39 | 0 | if (other_peak_mem > this->max_peak_memory_bytes) { |
40 | 0 | this->max_peak_memory_bytes = other_peak_mem; |
41 | 0 | } |
42 | |
|
43 | 0 | int64_t other_memory_used = other.current_used_memory_bytes; |
44 | 0 | if (other_memory_used > 0) { |
45 | 0 | this->current_used_memory_bytes = other_memory_used; |
46 | 0 | } |
47 | 0 | } |
48 | | |
49 | 0 | void QueryStatistics::to_pb(PQueryStatistics* statistics) { |
50 | 0 | DCHECK(statistics != nullptr); |
51 | 0 | statistics->set_scan_rows(scan_rows); |
52 | 0 | statistics->set_scan_bytes(scan_bytes); |
53 | 0 | statistics->set_cpu_ms(cpu_nanos / NANOS_PER_MILLIS); |
54 | 0 | statistics->set_returned_rows(returned_rows); |
55 | 0 | statistics->set_max_peak_memory_bytes(max_peak_memory_bytes); |
56 | 0 | statistics->set_scan_bytes_from_remote_storage(_scan_bytes_from_remote_storage); |
57 | 0 | statistics->set_scan_bytes_from_local_storage(_scan_bytes_from_local_storage); |
58 | 0 | } |
59 | | |
60 | 0 | void QueryStatistics::to_thrift(TQueryStatistics* statistics) const { |
61 | 0 | DCHECK(statistics != nullptr); |
62 | 0 | statistics->__set_scan_bytes(scan_bytes); |
63 | 0 | statistics->__set_scan_rows(scan_rows); |
64 | 0 | statistics->__set_cpu_ms(cpu_nanos / NANOS_PER_MILLIS); |
65 | 0 | statistics->__set_returned_rows(returned_rows); |
66 | 0 | statistics->__set_max_peak_memory_bytes(max_peak_memory_bytes); |
67 | 0 | statistics->__set_current_used_memory_bytes(current_used_memory_bytes); |
68 | 0 | statistics->__set_shuffle_send_bytes(shuffle_send_bytes); |
69 | 0 | statistics->__set_shuffle_send_rows(shuffle_send_rows); |
70 | 0 | statistics->__set_scan_bytes_from_remote_storage(_scan_bytes_from_remote_storage); |
71 | 0 | statistics->__set_scan_bytes_from_local_storage(_scan_bytes_from_local_storage); |
72 | 0 | } |
73 | | |
74 | 0 | void QueryStatistics::from_pb(const PQueryStatistics& statistics) { |
75 | 0 | scan_rows = statistics.scan_rows(); |
76 | 0 | scan_bytes = statistics.scan_bytes(); |
77 | 0 | cpu_nanos = statistics.cpu_ms() * NANOS_PER_MILLIS; |
78 | 0 | _scan_bytes_from_local_storage = statistics.scan_bytes_from_local_storage(); |
79 | 0 | _scan_bytes_from_remote_storage = statistics.scan_bytes_from_remote_storage(); |
80 | 0 | } |
81 | | |
82 | 18 | QueryStatistics::~QueryStatistics() {} |
83 | | |
84 | | } // namespace doris |