#pragma once #include #include #include namespace DB { class ReadBuffer; template class BinaryFormatReader; /** A stream for inputting data in a binary line-by-line format. */ template class BinaryRowInputFormat final : public RowInputFormatWithNamesAndTypes> { public: BinaryRowInputFormat(ReadBuffer & in_, const Block & header, IRowInputFormat::Params params_, bool with_names_, bool with_types_, const FormatSettings & format_settings_); String getName() const override { return "BinaryRowInputFormat"; } /// RowInputFormatWithNamesAndTypes implements logic with DiagnosticInfo, but /// in this format we cannot provide any DiagnosticInfo, because here we have /// just binary data. std::string getDiagnosticInfo() override { return {}; } }; template class BinaryFormatReader final : public FormatWithNamesAndTypesReader { public: BinaryFormatReader(ReadBuffer & in_, const FormatSettings & format_settings_); bool readField(IColumn & column, const DataTypePtr & type, const SerializationPtr & serialization, bool is_last_file_column, const String & column_name) override; void skipField(size_t file_column) override; void skipNames() override; void skipTypes() override; void skipHeaderRow(); std::vector readNames() override; std::vector readTypes() override; std::vector readHeaderRow(); private: /// Data types read from input data. DataTypes read_data_types; UInt64 read_columns; }; class BinaryWithNamesAndTypesSchemaReader : public FormatWithNamesAndTypesSchemaReader { public: BinaryWithNamesAndTypesSchemaReader(ReadBuffer & in_, const FormatSettings & format_settings_); private: BinaryFormatReader reader; }; }