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:
|
2020-01-04 05:46:50 +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.
|
2020-01-04 05:46:50 +00:00
|
|
|
MMapReadBufferFromFile(const std::string & file_name_, size_t offset);
|
2018-06-13 02:52:03 +00:00
|
|
|
|
|
|
|
~MMapReadBufferFromFile() override;
|
|
|
|
|
|
|
|
void close();
|
|
|
|
|
2020-01-04 05:46:50 +00:00
|
|
|
std::string getFileName() const override;
|
|
|
|
|
2023-10-17 00:00:07 +00:00
|
|
|
bool isRegularLocalFile(size_t * out_view_offset) override;
|
|
|
|
|
2018-06-13 02:52:03 +00:00
|
|
|
private:
|
|
|
|
int fd = -1;
|
2020-01-04 05:46:50 +00:00
|
|
|
std::string file_name;
|
2018-06-13 02:52:03 +00:00
|
|
|
|
|
|
|
CurrentMetrics::Increment metric_increment{CurrentMetrics::OpenFileForRead};
|
|
|
|
|
2020-01-04 05:46:50 +00:00
|
|
|
void open();
|
2018-06-13 02:52:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|