mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 21:51:57 +00:00
44 lines
882 B
C++
44 lines
882 B
C++
|
#pragma once
|
||
|
#include <functional>
|
||
|
#include <DB/IO/WriteBuffer.h>
|
||
|
|
||
|
|
||
|
namespace DB
|
||
|
{
|
||
|
|
||
|
namespace ErrorCodes
|
||
|
{
|
||
|
extern const int CURRENT_WRITE_BUFFER_IS_EXHAUSTED;
|
||
|
}
|
||
|
|
||
|
|
||
|
class CascadeWriteBuffer : public WriteBuffer
|
||
|
{
|
||
|
public:
|
||
|
|
||
|
using WriteBufferPtrs = std::vector<WriteBufferPtr>;
|
||
|
using WriteBufferConstructor = std::function<WriteBufferPtr (const WriteBufferPtr & prev_buf)>;
|
||
|
using WriteBufferConstructors = std::vector<WriteBufferConstructor>;
|
||
|
|
||
|
CascadeWriteBuffer(WriteBufferPtrs && prepared_sources_, WriteBufferConstructors && lazy_sources_ = {});
|
||
|
|
||
|
void nextImpl() override;
|
||
|
|
||
|
/// Should be called once
|
||
|
void getResultBuffers(WriteBufferPtrs & res);
|
||
|
|
||
|
private:
|
||
|
|
||
|
WriteBuffer * getNextBuffer();
|
||
|
|
||
|
WriteBufferPtrs prepared_sources;
|
||
|
WriteBufferConstructors lazy_sources;
|
||
|
size_t first_lazy_source_num;
|
||
|
size_t num_sources;
|
||
|
|
||
|
WriteBuffer * curr_buffer;
|
||
|
size_t curr_buffer_num;
|
||
|
};
|
||
|
|
||
|
}
|