Coverage Report

Created: 2026-07-20 14:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/runtime/file_scan_profile.h
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
#pragma once
19
20
#include "runtime/runtime_profile.h"
21
22
namespace doris::file_scan_profile {
23
24
inline constexpr const char* SCANNER = "FileScannerV2";
25
inline constexpr const char* TABLE_READER = "TableReader";
26
inline constexpr const char* FILE_READER = "FileReader";
27
inline constexpr const char* IO = "IO";
28
29
struct Hierarchy {
30
    RuntimeProfile::Counter* scanner = nullptr;
31
    RuntimeProfile::Counter* table_reader = nullptr;
32
    RuntimeProfile::Counter* file_reader = nullptr;
33
    RuntimeProfile::Counter* io = nullptr;
34
};
35
36
228k
inline Hierarchy ensure_hierarchy(RuntimeProfile* profile) {
37
228k
    if (profile == nullptr) {
38
0
        return {};
39
0
    }
40
    // RuntimeProfile stores one flat counter namespace and a separate parent map. Create every
41
    // layer in order so later format and IO profiles cannot accidentally become scanner siblings.
42
228k
    auto* scanner = ADD_TIMER_WITH_LEVEL(profile, SCANNER, 1);
43
228k
    auto* table_reader = ADD_CHILD_TIMER_WITH_LEVEL(profile, TABLE_READER, SCANNER, 1);
44
228k
    auto* file_reader = ADD_CHILD_TIMER_WITH_LEVEL(profile, FILE_READER, TABLE_READER, 1);
45
228k
    auto* io = ADD_CHILD_TIMER_WITH_LEVEL(profile, IO, FILE_READER, 1);
46
228k
    return {scanner, table_reader, file_reader, io};
47
228k
}
48
49
191k
inline const char* parent_or_root(RuntimeProfile* profile, const char* preferred_parent) {
50
191k
    return profile != nullptr && profile->get_counter(preferred_parent) != nullptr
51
191k
                   ? preferred_parent
52
191k
                   : RuntimeProfile::ROOT_COUNTER.c_str();
53
191k
}
54
55
} // namespace doris::file_scan_profile