aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Disks/IO/WriteBufferFromTemporaryFile.h
blob: 3e909dbcaaae63dff4cc85e06765b83baaea8328 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once
#include <IO/WriteBuffer.h>
#include <IO/IReadableWriteBuffer.h>
#include <IO/WriteBufferFromFile.h>
#include <Common/filesystemHelpers.h>


namespace DB
{

class TemporaryFileOnDisk;
using TemporaryFileOnDiskHolder = std::unique_ptr<TemporaryFileOnDisk>;

/// Rereadable WriteBuffer, could be used as disk buffer
/// Creates unique temporary in directory (and directory itself)
class WriteBufferFromTemporaryFile : public WriteBufferFromFile, public IReadableWriteBuffer
{
public:
    explicit WriteBufferFromTemporaryFile(TemporaryFileOnDiskHolder && tmp_file_);

    ~WriteBufferFromTemporaryFile() override;

private:
    std::shared_ptr<ReadBuffer> getReadBufferImpl() override;

    TemporaryFileOnDiskHolder tmp_file;

    friend class ReadBufferFromTemporaryWriteBuffer;
};

}