mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-19 21:03:51 +00:00
33 lines
824 B
C++
33 lines
824 B
C++
#pragma once
|
|
#include <IO/WriteBuffer.h>
|
|
#include <IO/IReadableWriteBuffer.h>
|
|
#include <IO/WriteBufferFromFile.h>
|
|
#include <Common/filesystemHelpers.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;
|
|
|
|
private:
|
|
explicit WriteBufferFromTemporaryFile(std::unique_ptr<TemporaryFile> && tmp_file);
|
|
|
|
std::shared_ptr<ReadBuffer> getReadBufferImpl() override;
|
|
|
|
std::unique_ptr<TemporaryFile> tmp_file;
|
|
|
|
friend class ReadBufferFromTemporaryWriteBuffer;
|
|
};
|
|
|
|
}
|