ClickHouse/src/QueryPipeline/RemoteInserter.h
2021-10-15 23:18:20 +03:00

47 lines
932 B
C++

#pragma once
#include <Core/Block.h>
#include <Common/Throttler.h>
#include <IO/ConnectionTimeouts.h>
#include <Interpreters/ClientInfo.h>
namespace DB
{
class Connection;
class ReadBuffer;
struct Settings;
/** Allow to execute INSERT query on remote server and send data for it.
*/
class RemoteInserter
{
public:
RemoteInserter(
Connection & connection_,
const ConnectionTimeouts & timeouts,
const String & query_,
const Settings & settings_,
const ClientInfo & client_info_);
void write(Block block);
void onFinish();
/// Send pre-serialized and possibly pre-compressed block of data, that will be read from 'input'.
void writePrepared(ReadBuffer & buf, size_t size = 0);
~RemoteInserter();
const Block & getHeader() const { return header; }
private:
Connection & connection;
String query;
Block header;
bool finished = false;
};
}