Coverage Report

Created: 2026-04-22 07:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format/table/fileset_reader.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 <cstddef>
21
#include <map>
22
#include <string>
23
#include <unordered_map>
24
#include <vector>
25
26
#include "common/factory_creator.h"
27
#include "format/generic_reader.h"
28
#include "io/file_factory.h"
29
#include "runtime/runtime_profile.h"
30
31
namespace doris {
32
class RuntimeProfile;
33
class RuntimeState;
34
class SlotDescriptor;
35
36
class FilesetReader : public GenericReader {
37
    ENABLE_FACTORY_CREATOR(FilesetReader);
38
39
public:
40
    FilesetReader(const std::vector<SlotDescriptor*>& file_slot_descs, RuntimeState* state,
41
                  RuntimeProfile* profile,
42
                  const std::map<std::string, std::string>& fileset_params);
43
8
    ~FilesetReader() override = default;
44
45
    Status init_reader();
46
    Status _do_get_next_block(Block* block, size_t* read_rows, bool* eof) override;
47
    Status _get_columns_impl(std::unordered_map<std::string, DataTypePtr>* name_to_type) override;
48
49
private:
50
    struct FilesetProfile {
51
        RuntimeProfile::Counter* listed_files = nullptr;
52
        RuntimeProfile::Counter* listed_bytes = nullptr;
53
        RuntimeProfile::Counter* emitted_rows = nullptr;
54
        RuntimeProfile::Counter* list_files_time = nullptr;
55
        RuntimeProfile::Counter* serialize_time = nullptr;
56
    };
57
58
    Status _build_files();
59
    // Lists files in the directory and filters by the glob pattern from _fileset_params.
60
    // Uses POSIX fnmatch(3) for pattern matching (supports *, ?, [...]).
61
    Status _list_files(const io::FileSystemSPtr& fs, const std::string& table_path);
62
    static Result<TFileType::type> _parse_file_type(const std::string& file_type);
63
    static std::string _build_uri(const std::string& table_path, const std::string& listed_name);
64
    void _init_profile();
65
    void _write_file_jsonb(JsonbWriter& writer, const io::FileInfo& file);
66
67
    const std::vector<SlotDescriptor*>& _file_slot_descs;
68
    RuntimeState* _state;
69
    RuntimeProfile* _profile;
70
    FilesetProfile _fileset_profile;
71
    std::map<std::string, std::string> _fileset_params;
72
    std::vector<io::FileInfo> _files;
73
    size_t _next_file_idx = 0;
74
};
75
} // namespace doris