Coverage Report

Created: 2026-03-12 16:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/io/fs/broker_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 <gen_cpp/PaloBrokerService_types.h>
21
#include <gen_cpp/Types_types.h>
22
23
#include <atomic>
24
#include <memory>
25
26
#include "common/status.h"
27
#include "io/fs/broker_file_system.h"
28
#include "io/fs/file_reader.h"
29
#include "io/fs/file_system.h"
30
#include "io/fs/path.h"
31
#include "util/client_cache.h"
32
#include "util/slice.h"
33
34
namespace doris::io {
35
36
struct IOContext;
37
38
class BrokerFileReader final : public FileReader {
39
public:
40
    BrokerFileReader(const TNetworkAddress& broker_addr, Path path, size_t file_size, TBrokerFD fd,
41
                     std::shared_ptr<BrokerServiceConnection> connection, int64_t mtime = 0);
42
43
    ~BrokerFileReader() override;
44
45
    Status close() override;
46
47
0
    const Path& path() const override { return _path; }
48
49
0
    size_t size() const override { return _file_size; }
50
51
0
    bool closed() const override { return _closed.load(std::memory_order_acquire); }
52
53
0
    int64_t mtime() const override { return _mtime; }
54
55
protected:
56
    Status read_at_impl(size_t offset, Slice result, size_t* bytes_read,
57
                        const IOContext* io_ctx) override;
58
59
private:
60
    const Path _path;
61
    size_t _file_size;
62
63
    const TNetworkAddress _broker_addr;
64
    TBrokerFD _fd;
65
66
    std::shared_ptr<BrokerServiceConnection> _connection;
67
    int64_t _mtime;
68
    std::atomic<bool> _closed = false;
69
};
70
} // namespace doris::io