ClickHouse/dbms/src/Formats/RowInputStreamWithDiagnosticInfo.h

50 lines
1.6 KiB
C++
Raw Normal View History

2019-04-14 20:01:03 +00:00
#pragma once
#include <Core/Block.h>
#include <Formats/IRowInputStream.h>
#include <IO/ReadBuffer.h>
2019-04-17 18:10:24 +00:00
#include <limits>
2019-04-14 20:01:03 +00:00
namespace DB
{
class RowInputStreamWithDiagnosticInfo : public IRowInputStream
{
public:
RowInputStreamWithDiagnosticInfo(ReadBuffer & istr_, const Block & header_);
String getDiagnosticInfo() override;
protected:
void updateDiagnosticInfo();
bool deserializeFieldAndPrintDiagnosticInfo(const String & col_name, const DataTypePtr & type, IColumn & column,
WriteBuffer & out, size_t input_position);
String alignedName(const String & name, size_t max_length) const;
virtual bool parseRowAndPrintDiagnosticInfo(MutableColumns & columns, WriteBuffer & out) = 0;
virtual void tryDeserializeFiled(const DataTypePtr & type, IColumn & column, size_t input_position, ReadBuffer::Position & prev_pos,
ReadBuffer::Position & curr_pos) = 0;
virtual bool isGarbageAfterField(size_t after_input_pos_idx, ReadBuffer::Position pos) = 0;
ReadBuffer & istr;
Block header;
/// 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;
};
}