aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/IO/MMapReadBufferFromFile.h
blob: bc566a0489ca2c558ed4ffb3c1a389bcb4ccc79b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once

#include <Common/CurrentMetrics.h>
#include <IO/MMapReadBufferFromFileDescriptor.h>


namespace CurrentMetrics
{
    extern const Metric OpenFileForRead;
}


namespace DB
{

class MMapReadBufferFromFile : public MMapReadBufferFromFileDescriptor
{
public:
    MMapReadBufferFromFile(const std::string & file_name_, size_t offset, size_t length_);

    /// Map till end of file.
    MMapReadBufferFromFile(const std::string & file_name_, size_t offset);

    ~MMapReadBufferFromFile() override;

    void close();

    std::string getFileName() const override;

private:
    int fd = -1;
    std::string file_name;

    CurrentMetrics::Increment metric_increment{CurrentMetrics::OpenFileForRead};

    void open();
};

}