ClickHouse/dbms/src/DataStreams/RemoteBlockOutputStream.h

44 lines
1018 B
C++
Raw Normal View History

2012-05-21 20:38:34 +00:00
#pragma once
#include <Core/Block.h>
#include <DataStreams/IBlockOutputStream.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:
RemoteBlockOutputStream(Connection & connection_, const String & query_, const Settings * settings_ = nullptr);
2012-05-21 20:38:34 +00:00
/// You can call this method after 'writePrefix', to get table required structure. (You must send data with that structure).
Block getSampleBlock() const
{
return sample_block;
}
void writePrefix() override;
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
private:
Connection & connection;
String query;
const Settings * settings;
Block sample_block;
2012-05-21 20:38:34 +00:00
};
}