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

44 lines
1.2 KiB
C++
Raw Normal View History

2019-02-19 18:41:18 +00:00
#pragma once
#include "config_formats.h"
2019-02-19 18:41:18 +00:00
#if USE_CAPNP
#include <Core/Block.h>
#include <Formats/CapnProtoUtils.h>
2019-02-19 18:41:18 +00:00
#include <Processors/Formats/IRowInputFormat.h>
namespace DB
{
class FormatSchemaInfo;
class ReadBuffer;
/** A stream for reading messages in Cap'n Proto format in given schema.
* Like Protocol Buffers and Thrift (but unlike JSON or MessagePack),
* Cap'n Proto messages are strongly-typed and not self-describing.
* The schema in this case cannot be compiled in, so it uses a runtime schema parser.
* See https://capnproto.org/cxx.html
*/
class CapnProtoRowInputFormat : public IRowInputFormat
{
public:
CapnProtoRowInputFormat(ReadBuffer & in_, Block header, Params params_, const FormatSchemaInfo & info, const FormatSettings & format_settings_);
2019-02-19 18:41:18 +00:00
String getName() const override { return "CapnProtoRowInputFormat"; }
2021-11-02 13:40:41 +00:00
private:
2019-02-19 18:41:18 +00:00
bool readRow(MutableColumns & columns, RowReadExtension &) override;
2019-08-01 08:31:08 +00:00
kj::Array<capnp::word> readMessage();
std::shared_ptr<CapnProtoSchemaParser> parser;
2019-02-19 18:41:18 +00:00
capnp::StructSchema root;
const FormatSettings format_settings;
DataTypes column_types;
Names column_names;
2019-02-19 18:41:18 +00:00
};
}
#endif // USE_CAPNP