1#pragma once
2
3#include <Common/CurrentMetrics.h>
4#include <IO/MMapReadBufferFromFileDescriptor.h>
5
6
7namespace CurrentMetrics
8{
9 extern const Metric OpenFileForRead;
10}
11
12
13namespace DB
14{
15
16class MMapReadBufferFromFile : public MMapReadBufferFromFileDescriptor
17{
18public:
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
28private:
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