2019-02-19 18:41:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Core/Block.h>
|
2021-10-14 12:05:49 +00:00
|
|
|
#include <Processors/Formats/RowInputFormatWithNamesAndTypes.h>
|
2021-12-15 11:30:57 +00:00
|
|
|
#include <Processors/Formats/ISchemaReader.h>
|
2019-02-19 18:41:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-12-15 11:30:57 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int NOT_IMPLEMENTED;
|
|
|
|
}
|
2019-02-19 18:41:18 +00:00
|
|
|
|
2021-12-15 11:30:57 +00:00
|
|
|
class ReadBuffer;
|
2019-02-19 18:41:18 +00:00
|
|
|
|
|
|
|
/** A stream for inputting data in a binary line-by-line format.
|
|
|
|
*/
|
2022-02-06 04:14:01 +00:00
|
|
|
class BinaryRowInputFormat final : public RowInputFormatWithNamesAndTypes
|
2019-02-19 18:41:18 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-10-20 11:48:54 +00:00
|
|
|
BinaryRowInputFormat(ReadBuffer & in_, Block header, Params params_, bool with_names_, bool with_types_, const FormatSettings & format_settings_);
|
2019-02-19 18:41:18 +00:00
|
|
|
|
|
|
|
String getName() const override { return "BinaryRowInputFormat"; }
|
|
|
|
|
2021-10-14 12:05:49 +00:00
|
|
|
/// 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 {}; }
|
2021-12-15 11:30:57 +00:00
|
|
|
};
|
|
|
|
|
2022-02-06 04:14:01 +00:00
|
|
|
class BinaryFormatReader final : public FormatWithNamesAndTypesReader
|
2021-12-15 11:30:57 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
BinaryFormatReader(ReadBuffer & in_, const FormatSettings & format_settings_);
|
2021-10-14 12:05:49 +00:00
|
|
|
|
|
|
|
bool readField(IColumn & column, const DataTypePtr & type, const SerializationPtr & serialization, bool is_last_file_column, const String & column_name) override;
|
2021-12-15 11:30:57 +00:00
|
|
|
|
2021-10-14 12:05:49 +00:00
|
|
|
void skipField(size_t file_column) override;
|
|
|
|
|
|
|
|
void skipNames() override;
|
|
|
|
void skipTypes() override;
|
|
|
|
void skipHeaderRow();
|
|
|
|
|
|
|
|
std::vector<String> readNames() override;
|
|
|
|
std::vector<String> readTypes() override;
|
|
|
|
std::vector<String> readHeaderRow();
|
|
|
|
|
2021-12-15 11:30:57 +00:00
|
|
|
private:
|
2021-10-27 19:16:34 +00:00
|
|
|
/// Data types read from input data.
|
2021-10-14 12:05:49 +00:00
|
|
|
DataTypes read_data_types;
|
2021-12-15 11:30:57 +00:00
|
|
|
UInt64 read_columns;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BinaryWithNamesAndTypesSchemaReader : public FormatWithNamesAndTypesSchemaReader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BinaryWithNamesAndTypesSchemaReader(ReadBuffer & in_, const FormatSettings & format_settings_);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DataTypes readRowAndGetDataTypes() override
|
|
|
|
{
|
|
|
|
throw Exception{ErrorCodes::NOT_IMPLEMENTED, "Method readRowAndGetDataTypes is not implemented"};
|
|
|
|
}
|
|
|
|
|
|
|
|
BinaryFormatReader reader;
|
2019-02-19 18:41:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|