Coverage Report

Created: 2026-03-14 13:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/io/fs/local_file_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 <atomic>
21
#include <memory>
22
23
#include "common/status.h"
24
#include "io/fs/file_reader.h"
25
#include "io/fs/file_system.h"
26
#include "io/fs/path.h"
27
#include "util/slice.h"
28
29
namespace doris {
30
struct StorePath;
31
struct DataDirInfo;
32
struct CachePath;
33
} // namespace doris
34
35
namespace doris::io {
36
37
struct BeConfDataDirReader {
38
    static std::atomic_int be_config_data_dir_list_state;
39
    static std::vector<doris::DataDirInfo> be_config_data_dir_list;
40
41
    static void get_data_dir_by_file_path(Path* file_path, std::string* data_dir_arg);
42
43
    static void init_be_conf_data_dir(const std::vector<doris::StorePath>& store_paths,
44
                                      const std::vector<doris::StorePath>& spill_store_paths,
45
                                      const std::vector<doris::CachePath>& cache_paths);
46
};
47
48
struct IOContext;
49
50
class LocalFileReader final : public FileReader {
51
public:
52
    LocalFileReader(Path path, size_t file_size, int fd);
53
54
    ~LocalFileReader() override;
55
56
    Status close() override;
57
58
101k
    const Path& path() const override { return _path; }
59
60
104k
    size_t size() const override { return _file_size; }
61
62
21.3M
    bool closed() const override { return _closed.load(std::memory_order_acquire); }
63
64
39.7M
    const std::string& get_data_dir_path() override { return _data_dir_path; }
65
66
477
    int64_t mtime() const override { return 0; }
67
68
private:
69
    Status read_at_impl(size_t offset, Slice result, size_t* bytes_read,
70
                        const IOContext* io_ctx) override;
71
72
private:
73
    int _fd = -1; // owned
74
    Path _path;
75
    size_t _file_size;
76
    std::atomic<bool> _closed = false;
77
    std::string _data_dir_path; // be conf's data dir path
78
};
79
80
} // namespace doris::io