Coverage Report

Created: 2026-07-03 17:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format_v2/file_reader.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 "format_v2/file_reader.h"
19
20
#include <sstream>
21
22
#include "format_v2/column_mapper.h"
23
#include "io/fs/buffered_reader.h"
24
#include "io/fs/tracing_file_reader.h"
25
#include "runtime/runtime_state.h"
26
27
namespace doris::format {
28
namespace {
29
30
template <typename T, typename Formatter>
31
0
std::string join_debug_strings(const std::vector<T>& values, Formatter formatter) {
32
0
    std::ostringstream out;
33
0
    out << "[";
34
0
    for (size_t i = 0; i < values.size(); ++i) {
35
0
        if (i > 0) {
36
0
            out << ", ";
37
0
        }
38
0
        out << formatter(values[i]);
39
0
    }
40
0
    out << "]";
41
0
    return out.str();
42
0
}
Unexecuted instantiation: file_reader.cpp:_ZN5doris6format12_GLOBAL__N_118join_debug_stringsINS0_16LocalColumnIndexEZNKS0_15FileScanRequest12debug_stringB5cxx11EvE3$_0EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISD_EET0_
Unexecuted instantiation: file_reader.cpp:_ZN5doris6format12_GLOBAL__N_118join_debug_stringsINS0_16LocalColumnIndexEZNKS0_15FileScanRequest12debug_stringB5cxx11EvE3$_1EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISD_EET0_
Unexecuted instantiation: file_reader.cpp:_ZN5doris6format12_GLOBAL__N_118join_debug_stringsINS0_25FileColumnPredicateFilterEZNKS0_15FileScanRequest12debug_stringB5cxx11EvE3$_2EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISD_EET0_
43
44
} // namespace
45
46
0
std::string FileColumnPredicateFilter::debug_string() const {
47
0
    std::ostringstream out;
48
0
    out << "FileColumnPredicateFilter{file_column_id=" << file_column_id
49
0
        << ", predicate_count=" << predicates.size() << "}";
50
0
    return out.str();
51
0
}
52
53
0
std::string FileScanRequest::debug_string() const {
54
0
    std::ostringstream out;
55
0
    out << "FileScanRequest{predicate_columns="
56
0
        << join_debug_strings(
57
0
                   predicate_columns,
58
0
                   [](const LocalColumnIndex& projection) { return projection.debug_string(); })
59
0
        << ", non_predicate_columns="
60
0
        << join_debug_strings(
61
0
                   non_predicate_columns,
62
0
                   [](const LocalColumnIndex& projection) { return projection.debug_string(); })
63
0
        << ", local_positions={";
64
0
    size_t position_idx = 0;
65
0
    for (const auto& [column_id, block_position] : local_positions) {
66
0
        if (position_idx++ > 0) {
67
0
            out << ", ";
68
0
        }
69
0
        out << column_id << ":" << block_position;
70
0
    }
71
0
    out << "}, conjunct_count=" << conjuncts.size()
72
0
        << ", delete_conjunct_count=" << delete_conjuncts.size() << ", column_predicate_filters="
73
0
        << join_debug_strings(
74
0
                   column_predicate_filters,
75
0
                   [](const FileColumnPredicateFilter& filter) { return filter.debug_string(); })
76
0
        << "}";
77
0
    return out.str();
78
0
}
79
80
230
Status FileReader::init(RuntimeState* state) {
81
230
    _init_profile();
82
230
    SCOPED_RAW_TIMER(&_reader_statistics.file_reader_create_time);
83
230
    ++_reader_statistics.open_file_num;
84
230
    io::FileReaderOptions reader_options =
85
230
            FileFactory::get_reader_options(state->query_options(), *_file_description);
86
230
    _file_reader = DORIS_TRY(io::DelegateReader::create_file_reader(
87
230
            _profile, *_system_properties, *_file_description, reader_options,
88
230
            io::DelegateReader::AccessMode::RANDOM, _io_ctx));
89
    // IOContext can be present without file_reader_stats in standalone tests or callers that only
90
    // need extra IO state. TracingFileReader dereferences the stats pointer on every read, so only
91
    // wrap the physical reader when stats collection is actually available.
92
230
    _tracing_file_reader = _io_ctx && _io_ctx->file_reader_stats
93
230
                                   ? std::make_shared<io::TracingFileReader>(
94
131
                                             _file_reader, _io_ctx->file_reader_stats)
95
230
                                   : _file_reader;
96
230
    _eof = false;
97
230
    return Status::OK();
98
230
}
99
100
std::unique_ptr<TableColumnMapper> FileReader::create_column_mapper(
101
8
        TableColumnMapperOptions options) const {
102
8
    return std::make_unique<TableColumnMapper>(std::move(options));
103
8
}
104
105
} // namespace doris::format