ClickHouse/dbms/DataStreams/RemoteBlockOutputStream.h

48 lines
1.2 KiB
C++
Raw Normal View History

2012-05-21 20:38:34 +00:00
#pragma once
#include <Core/Block.h>
#include <DataStreams/IBlockOutputStream.h>
#include <Common/Throttler.h>
2019-03-07 23:11:41 +00:00
#include <IO/ConnectionTimeouts.h>
2012-05-21 20:38:34 +00:00
namespace DB
{
class Connection;
class ReadBuffer;
struct Settings;
/** Allow to execute INSERT query on remote server and send data for it.
2012-05-21 20:38:34 +00:00
*/
class RemoteBlockOutputStream : public IBlockOutputStream
{
public:
2019-03-07 23:11:41 +00:00
RemoteBlockOutputStream(Connection & connection_,
const ConnectionTimeouts & timeouts,
const String & query_,
const Settings * settings_ = nullptr,
const ClientInfo * client_info_ = nullptr);
2012-05-21 20:38:34 +00:00
Block getHeader() const override { return header; }
2012-05-21 20:38:34 +00:00
void write(const Block & block) override;
void writeSuffix() override;
/// Send pre-serialized and possibly pre-compressed block of data, that will be read from 'input'.
void writePrepared(ReadBuffer & input, size_t size = 0);
2012-05-21 20:38:34 +00:00
~RemoteBlockOutputStream() override;
2012-05-21 20:38:34 +00:00
private:
Connection & connection;
String query;
const Settings * settings;
const ClientInfo * client_info;
Block header;
bool finished = false;
2012-05-21 20:38:34 +00:00
};
}