mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-05 15:21:43 +00:00
d36f52502e
It's still hackish and dirty, but server and client compies. Server starts, but throwes meaningless exception on any query. Client seems to be working fine. Linux compilation might (but shouldn't) be broken (not tested).
47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <DB/IO/ReadBufferFromFileDescriptor.h>
|
|
#include <DB/Common/CurrentMetrics.h>
|
|
|
|
#ifndef O_DIRECT
|
|
#define O_DIRECT 00040000
|
|
#endif
|
|
|
|
namespace CurrentMetrics
|
|
{
|
|
extern const Metric OpenFileForRead;
|
|
}
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/** Accepts path to file and opens it, or pre-opened file descriptor.
|
|
* Closes file by himself (thus "owns" a file descriptor).
|
|
*/
|
|
class ReadBufferFromFile : public ReadBufferFromFileDescriptor
|
|
{
|
|
private:
|
|
std::string file_name;
|
|
CurrentMetrics::Increment metric_increment{CurrentMetrics::OpenFileForRead};
|
|
|
|
public:
|
|
ReadBufferFromFile(const std::string & file_name_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, int flags = -1,
|
|
char * existing_memory = nullptr, size_t alignment = 0);
|
|
|
|
/// Use pre-opened file descriptor.
|
|
ReadBufferFromFile(int fd, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, int flags = -1,
|
|
char * existing_memory = nullptr, size_t alignment = 0);
|
|
|
|
~ReadBufferFromFile() override;
|
|
|
|
/// Close file before destruction of object.
|
|
void close();
|
|
|
|
std::string getFileName() const override
|
|
{
|
|
return file_name;
|
|
}
|
|
};
|
|
|
|
}
|