1 | #include <IO/WriteBuffer.h> |
---|---|
2 | #include <IO/IReadableWriteBuffer.h> |
3 | #include <IO/WriteBufferFromFile.h> |
4 | #include <Common/filesystemHelpers.h> |
5 | |
6 | |
7 | namespace DB |
8 | { |
9 | |
10 | /// Rereadable WriteBuffer, could be used as disk buffer |
11 | /// Creates unique temporary in directory (and directory itself) |
12 | class WriteBufferFromTemporaryFile : public WriteBufferFromFile, public IReadableWriteBuffer |
13 | { |
14 | public: |
15 | using Ptr = std::shared_ptr<WriteBufferFromTemporaryFile>; |
16 | |
17 | static Ptr create(const std::string & tmp_dir); |
18 | |
19 | ~WriteBufferFromTemporaryFile() override; |
20 | |
21 | protected: |
22 | |
23 | WriteBufferFromTemporaryFile(std::unique_ptr<TemporaryFile> && tmp_file); |
24 | |
25 | std::shared_ptr<ReadBuffer> getReadBufferImpl() override; |
26 | |
27 | protected: |
28 | |
29 | std::unique_ptr<TemporaryFile> tmp_file; |
30 | |
31 | friend class ReadBufferFromTemporaryWriteBuffer; |
32 | }; |
33 | |
34 | } |
35 |