ClickHouse/src/Processors/Formats/Impl/MySQLOutputFormat.h

53 lines
1.3 KiB
C++
Raw Normal View History

2019-07-04 18:55:20 +00:00
#pragma once
#include <Processors/Formats/IRowOutputFormat.h>
#include <Core/Block.h>
2020-08-13 12:07:02 +00:00
#include <Core/MySQL/Authentication.h>
#include <Core/MySQL/PacketsGeneric.h>
#include <Core/MySQL/PacketsConnection.h>
#include <Core/MySQL/PacketsProtocolText.h>
2019-07-04 18:55:20 +00:00
#include <Formats/FormatSettings.h>
namespace DB
{
class IColumn;
class IDataType;
class WriteBuffer;
class Context;
/** A stream for outputting data in a binary line-by-line format.
*/
class MySQLOutputFormat final : public IOutputFormat
2019-07-04 18:55:20 +00:00
{
public:
MySQLOutputFormat(WriteBuffer & out_, const Block & header_, const FormatSettings & settings_);
2019-07-04 18:55:20 +00:00
String getName() const override { return "MySQLOutputFormat"; }
void setContext(const Context & context_)
{
context = &context_;
2020-08-13 12:41:36 +00:00
packet_endpoint = std::make_unique<MySQLProtocol::PacketEndpoint>(out, const_cast<uint8_t &>(context_.mysql.sequence_id)); /// TODO: fix it
}
2019-07-04 18:55:20 +00:00
void consume(Chunk) override;
void finalize() override;
2019-08-02 12:41:21 +00:00
void flush() override;
2019-08-05 09:35:46 +00:00
void doWritePrefix() override { initialize(); }
void initialize();
2019-07-04 18:55:20 +00:00
private:
bool initialized = false;
const Context * context = nullptr;
2020-08-13 12:41:36 +00:00
std::unique_ptr<MySQLProtocol::PacketEndpoint> packet_endpoint;
2019-07-04 18:55:20 +00:00
FormatSettings format_settings;
2019-12-01 11:21:43 +00:00
DataTypes data_types;
2019-07-04 18:55:20 +00:00
};
}