2019-02-19 18:41:18 +00:00
|
|
|
#pragma once
|
2019-08-17 22:53:46 +00:00
|
|
|
|
|
|
|
#include "config_formats.h"
|
2019-02-19 18:41:18 +00:00
|
|
|
#if USE_CAPNP
|
|
|
|
|
|
|
|
#include <Core/Block.h>
|
2021-09-28 12:59:22 +00:00
|
|
|
#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:
|
2021-09-28 12:59:22 +00:00
|
|
|
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();
|
|
|
|
|
2021-09-28 12:59:22 +00:00
|
|
|
std::shared_ptr<CapnProtoSchemaParser> parser;
|
2019-02-19 18:41:18 +00:00
|
|
|
capnp::StructSchema root;
|
2021-09-28 12:59:22 +00:00
|
|
|
const FormatSettings format_settings;
|
|
|
|
DataTypes column_types;
|
|
|
|
Names column_names;
|
2019-02-19 18:41:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // USE_CAPNP
|