2019-04-14 20:01:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Core/Block.h>
|
2019-08-23 19:47:22 +00:00
|
|
|
#include <Processors/Formats/IRowInputFormat.h>
|
2019-04-14 20:01:03 +00:00
|
|
|
#include <IO/ReadBuffer.h>
|
2019-04-17 18:10:24 +00:00
|
|
|
#include <limits>
|
2019-04-14 20:01:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-08-23 19:47:22 +00:00
|
|
|
class RowInputFormatWithDiagnosticInfo : public IRowInputFormat
|
2019-04-14 20:01:03 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-08-23 19:47:22 +00:00
|
|
|
RowInputFormatWithDiagnosticInfo(const Block & header_, ReadBuffer & in_, const Params & params_);
|
2019-04-14 20:01:03 +00:00
|
|
|
|
|
|
|
String getDiagnosticInfo() override;
|
|
|
|
|
2019-11-26 23:46:19 +00:00
|
|
|
void resetParser() override;
|
|
|
|
|
2019-04-14 20:01:03 +00:00
|
|
|
protected:
|
|
|
|
void updateDiagnosticInfo();
|
|
|
|
bool deserializeFieldAndPrintDiagnosticInfo(const String & col_name, const DataTypePtr & type, IColumn & column,
|
2019-08-30 14:38:24 +00:00
|
|
|
WriteBuffer & out, size_t file_column);
|
2019-04-14 20:01:03 +00:00
|
|
|
|
|
|
|
virtual bool parseRowAndPrintDiagnosticInfo(MutableColumns & columns, WriteBuffer & out) = 0;
|
2019-08-30 14:38:24 +00:00
|
|
|
virtual void tryDeserializeFiled(const DataTypePtr & type, IColumn & column, size_t file_column,
|
|
|
|
ReadBuffer::Position & prev_pos, ReadBuffer::Position & curr_pos) = 0;
|
2019-04-14 20:01:03 +00:00
|
|
|
virtual bool isGarbageAfterField(size_t after_input_pos_idx, ReadBuffer::Position pos) = 0;
|
|
|
|
|
|
|
|
/// For convenient diagnostics in case of an error.
|
|
|
|
size_t row_num = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// How many bytes were read, not counting those still in the buffer.
|
|
|
|
size_t bytes_read_at_start_of_buffer_on_current_row = 0;
|
|
|
|
size_t bytes_read_at_start_of_buffer_on_prev_row = 0;
|
|
|
|
|
2019-04-17 18:10:24 +00:00
|
|
|
size_t offset_of_current_row = std::numeric_limits<size_t>::max();
|
|
|
|
size_t offset_of_prev_row = std::numeric_limits<size_t>::max();
|
2019-04-14 20:01:03 +00:00
|
|
|
|
|
|
|
/// For alignment of diagnostic info.
|
|
|
|
size_t max_length_of_column_name = 0;
|
|
|
|
size_t max_length_of_data_type_name = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|