2012-05-21 20:38:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-31 18:39:01 +00:00
|
|
|
#include <DB/Core/Block.h>
|
2012-05-21 20:38:34 +00:00
|
|
|
#include <DB/DataStreams/IBlockOutputStream.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-01-31 18:39:01 +00:00
|
|
|
class Connection;
|
|
|
|
class ReadBuffer;
|
|
|
|
struct Settings;
|
2016-01-11 21:46:36 +00:00
|
|
|
|
|
|
|
|
2017-01-31 18:39:01 +00:00
|
|
|
/** 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:
|
2017-01-31 18:39:01 +00:00
|
|
|
RemoteBlockOutputStream(Connection & connection_, const String & query_, const Settings * settings_ = nullptr);
|
2012-05-21 20:38:34 +00:00
|
|
|
|
|
|
|
|
2017-01-31 18:39:01 +00:00
|
|
|
/// You can call this method after 'writePrefix', to get table required structure. (You must send data with that structure).
|
2014-09-18 19:49:31 +00:00
|
|
|
Block getSampleBlock() const
|
2012-05-21 20:38:34 +00:00
|
|
|
{
|
2014-09-18 19:49:31 +00:00
|
|
|
return sample_block;
|
|
|
|
}
|
|
|
|
|
2017-01-31 18:39:01 +00:00
|
|
|
void writePrefix() override;
|
|
|
|
void write(const Block & block) override;
|
|
|
|
void writeSuffix() override;
|
2014-09-18 19:49:31 +00:00
|
|
|
|
2017-01-31 18:39:01 +00:00
|
|
|
/// 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;
|
2012-06-07 20:02:41 +00:00
|
|
|
String query;
|
2015-06-28 06:38:18 +00:00
|
|
|
const Settings * settings;
|
2014-06-05 12:02:18 +00:00
|
|
|
Block sample_block;
|
2012-05-21 20:38:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|