2019-02-21 18:36:46 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Common/config.h>
|
|
|
|
#if USE_PROTOBUF
|
|
|
|
|
|
|
|
#include <DataTypes/IDataType.h>
|
|
|
|
#include <Processors/Formats/IRowInputFormat.h>
|
|
|
|
#include <Formats/ProtobufReader.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
class Block;
|
|
|
|
class FormatSchemaInfo;
|
|
|
|
|
|
|
|
|
2019-08-02 16:23:44 +00:00
|
|
|
/** Stream designed to deserialize data from the google protobuf format.
|
|
|
|
* Each row is read as a separated message.
|
|
|
|
* These messages are delimited according to documentation
|
|
|
|
* https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/util/delimited_message_util.h
|
|
|
|
* Serializing in the protobuf format requires the 'format_schema' setting to be set, e.g.
|
|
|
|
* INSERT INTO table FORMAT Protobuf SETTINGS format_schema = 'schema:Message'
|
|
|
|
* where schema is the name of "schema.proto" file specifying protobuf schema.
|
2019-02-21 18:36:46 +00:00
|
|
|
*/
|
|
|
|
class ProtobufRowInputFormat : public IRowInputFormat
|
|
|
|
{
|
|
|
|
public:
|
2019-08-03 11:02:40 +00:00
|
|
|
ProtobufRowInputFormat(ReadBuffer & in_, const Block & header_, Params params_, const FormatSchemaInfo & info_);
|
2019-02-21 18:36:46 +00:00
|
|
|
~ProtobufRowInputFormat() override;
|
|
|
|
|
|
|
|
String getName() const override { return "ProtobufRowInputFormat"; }
|
|
|
|
|
|
|
|
bool readRow(MutableColumns & columns, RowReadExtension & extra) override;
|
|
|
|
bool allowSyncAfterError() const override;
|
|
|
|
void syncAfterError() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DataTypes data_types;
|
|
|
|
ProtobufReader reader;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|