1 | #pragma once |
2 | |
3 | #include <Common/CurrentMetrics.h> |
4 | #include <IO/MMapReadBufferFromFileDescriptor.h> |
5 | |
6 | |
7 | namespace CurrentMetrics |
8 | { |
9 | extern const Metric OpenFileForRead; |
10 | } |
11 | |
12 | |
13 | namespace DB |
14 | { |
15 | |
16 | class MMapReadBufferFromFile : public MMapReadBufferFromFileDescriptor |
17 | { |
18 | public: |
19 | MMapReadBufferFromFile(const std::string & file_name, size_t offset, size_t length_); |
20 | |
21 | /// Map till end of file. |
22 | MMapReadBufferFromFile(const std::string & file_name, size_t offset); |
23 | |
24 | ~MMapReadBufferFromFile() override; |
25 | |
26 | void close(); |
27 | |
28 | private: |
29 | int fd = -1; |
30 | |
31 | CurrentMetrics::Increment metric_increment{CurrentMetrics::OpenFileForRead}; |
32 | |
33 | void open(const std::string & file_name); |
34 | }; |
35 | |
36 | } |
37 | |
38 | |