aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/IO/ForkWriteBuffer.h
blob: 17fc82028a9364185a2b3a8ccd5d410b3942c0dc (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
32
33
34
#pragma once
#include <IO/WriteBuffer.h>


namespace DB
{

namespace ErrorCodes
{
}

/** ForkWriteBuffer takes a vector of WriteBuffer and writes data to all of them
 * If the vector of WriteBufferPts is empty, then it throws an error
 * It uses the buffer of the first element as its buffer and copies data from
 * first buffer to all the other buffers
 **/
class ForkWriteBuffer : public WriteBuffer
{
public:

    using WriteBufferPtrs = std::vector<WriteBufferPtr>;

    explicit ForkWriteBuffer(WriteBufferPtrs && sources_);
    ~ForkWriteBuffer() override;

protected:
    void nextImpl() override;
    void finalizeImpl() override;

private:
    WriteBufferPtrs sources;
};

}