| 1 | #pragma once |
|---|---|
| 2 | |
| 3 | #include <Core/Block.h> |
| 4 | #include <DataStreams/IBlockOutputStream.h> |
| 5 | #include <Common/Throttler.h> |
| 6 | #include <IO/ConnectionTimeouts.h> |
| 7 | |
| 8 | |
| 9 | namespace DB |
| 10 | { |
| 11 | |
| 12 | class Connection; |
| 13 | class ReadBuffer; |
| 14 | struct Settings; |
| 15 | |
| 16 | |
| 17 | /** Allow to execute INSERT query on remote server and send data for it. |
| 18 | */ |
| 19 | class RemoteBlockOutputStream : public IBlockOutputStream |
| 20 | { |
| 21 | public: |
| 22 | RemoteBlockOutputStream(Connection & connection_, |
| 23 | const ConnectionTimeouts & timeouts, |
| 24 | const String & query_, |
| 25 | const Settings * settings_ = nullptr); |
| 26 | |
| 27 | Block getHeader() const override { return header; } |
| 28 | |
| 29 | void write(const Block & block) override; |
| 30 | void writeSuffix() override; |
| 31 | |
| 32 | /// Send pre-serialized and possibly pre-compressed block of data, that will be read from 'input'. |
| 33 | void writePrepared(ReadBuffer & input, size_t size = 0); |
| 34 | |
| 35 | ~RemoteBlockOutputStream() override; |
| 36 | |
| 37 | private: |
| 38 | Connection & connection; |
| 39 | String query; |
| 40 | const Settings * settings; |
| 41 | Block header; |
| 42 | bool finished = false; |
| 43 | }; |
| 44 | |
| 45 | } |
| 46 |