2018-06-13 02:52:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Common/CurrentMetrics.h>
|
|
|
|
#include <IO/MMapReadBufferFromFileDescriptor.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace CurrentMetrics
|
|
|
|
{
|
|
|
|
extern const Metric OpenFileForRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class MMapReadBufferFromFile : public MMapReadBufferFromFileDescriptor
|
|
|
|
{
|
|
|
|
public:
|
2019-08-03 11:02:40 +00:00
|
|
|
MMapReadBufferFromFile(const std::string & file_name, size_t offset, size_t length_);
|
2018-06-13 02:52:03 +00:00
|
|
|
|
|
|
|
/// Map till end of file.
|
|
|
|
MMapReadBufferFromFile(const std::string & file_name, size_t offset);
|
|
|
|
|
|
|
|
~MMapReadBufferFromFile() override;
|
|
|
|
|
|
|
|
void close();
|
|
|
|
|
|
|
|
private:
|
|
|
|
int fd = -1;
|
|
|
|
|
|
|
|
CurrentMetrics::Increment metric_increment{CurrentMetrics::OpenFileForRead};
|
|
|
|
|
|
|
|
void open(const std::string & file_name);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|