mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 21:51:57 +00:00
35 lines
811 B
C++
35 lines
811 B
C++
#include <DB/IO/WriteBuffer.h>
|
|
#include <DB/IO/IReadableWriteBuffer.h>
|
|
#include <DB/IO/WriteBufferFromFile.h>
|
|
#include <Poco/TemporaryFile.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/// Rereadable WriteBuffer, could be used as disk buffer
|
|
/// Creates unique temporary in directory (and directory itself)
|
|
class WriteBufferFromTemporaryFile : public WriteBufferFromFile, public IReadableWriteBuffer
|
|
{
|
|
public:
|
|
using Ptr = std::shared_ptr<WriteBufferFromTemporaryFile>;
|
|
|
|
static Ptr create(const std::string & tmp_dir);
|
|
|
|
~WriteBufferFromTemporaryFile() override;
|
|
|
|
protected:
|
|
|
|
WriteBufferFromTemporaryFile(std::unique_ptr<Poco::TemporaryFile> && tmp_file);
|
|
|
|
std::shared_ptr<ReadBuffer> getReadBufferImpl() override;
|
|
|
|
protected:
|
|
|
|
std::unique_ptr<Poco::TemporaryFile> tmp_file;
|
|
|
|
friend class ReadBufferFromTemporaryWriteBuffer;
|
|
};
|
|
|
|
}
|