mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-14 03:25:15 +00:00
8b3afeb60d
commit f968e7e7f0d84c89fd26dea1d541bd9f6041d7c8 Author: Alexey Milovidov <milovidov@yandex-team.ru> Date: Tue Feb 16 06:11:29 2016 +0300 Addition [#METR-2944]. commit 7524981fa7c4f22929dd5009444a0ae28500f620 Author: Alexey Milovidov <milovidov@yandex-team.ru> Date: Tue Feb 16 06:08:43 2016 +0300 Fixed error (incomplete) [#METR-2944]. commit 2f1e7bf9f46cd9ce958ade9041c00ce067940fd2 Author: Alexey Milovidov <milovidov@yandex-team.ru> Date: Tue Feb 16 05:37:43 2016 +0300 Improving performance of row formats [#METR-2944]. commit 9848910f235863c9571ef1ebe0d87d4929ee283c Author: Alexey Milovidov <milovidov@yandex-team.ru> Date: Tue Feb 16 00:37:12 2016 +0300 Improving performance of text formats [#METR-2944]. commit 3aedc7fd784af962e64ffdd10ec23ac53827d8e2 Author: Alexey Milovidov <milovidov@yandex-team.ru> Date: Tue Feb 16 00:18:00 2016 +0300 Improving performance of row formats [#METR-2944]. commit cb5932c2b0385604477e69c8262dc31a4bb4b23b Author: Alexey Milovidov <milovidov@yandex-team.ru> Date: Mon Feb 15 00:53:27 2016 +0300 Fixed error. commit 42863fd4eddeef594e846c598b92877b6ff86fa6 Author: Alexey Milovidov <milovidov@yandex-team.ru> Date: Sun Feb 14 23:13:46 2016 +0300 Improving performance of row formats [#METR-2944]. commit 71c6fb19a85a79297433ceb486fdb97e551d964f Author: Alexey Milovidov <milovidov@yandex-team.ru> Date: Sun Feb 14 16:58:56 2016 +0300 Improving performance of row formats [#METR-2944].
67 lines
2.2 KiB
C++
67 lines
2.2 KiB
C++
#pragma once
|
||
|
||
#include <DB/Core/Block.h>
|
||
#include <DB/DataStreams/IRowInputStream.h>
|
||
|
||
|
||
namespace DB
|
||
{
|
||
|
||
class ReadBuffer;
|
||
class WriteBuffer;
|
||
|
||
/** Поток для ввода данных в формате csv.
|
||
* Не соответствует https://tools.ietf.org/html/rfc4180 потому что пропускает пробелы и табы между значениями.
|
||
*/
|
||
class CSVRowInputStream : public IRowInputStream
|
||
{
|
||
public:
|
||
/** with_names - в первой строке заголовок с именами столбцов
|
||
* with_types - на следующей строке заголовок с именами типов
|
||
*/
|
||
CSVRowInputStream(ReadBuffer & istr_, const Block & sample_, const char delimiter_, bool with_names_ = false, bool with_types_ = false);
|
||
|
||
bool read(Block & block) override;
|
||
void readPrefix() override;
|
||
|
||
private:
|
||
ReadBuffer & istr;
|
||
const Block sample;
|
||
const char delimiter;
|
||
bool with_names;
|
||
bool with_types;
|
||
DataTypes data_types;
|
||
|
||
/// Для удобной диагностики в случае ошибки.
|
||
|
||
size_t row_num = 0;
|
||
|
||
/// Сколько байт было считано, не считая тех, что ещё в буфере.
|
||
size_t bytes_read_at_start_of_buffer_on_current_row = 0;
|
||
size_t bytes_read_at_start_of_buffer_on_prev_row = 0;
|
||
|
||
char * pos_of_current_row = nullptr;
|
||
char * pos_of_prev_row = nullptr;
|
||
|
||
/** В случае исключения при парсинге, вызывается эта функция.
|
||
* Она выполняет заново парсинг последних двух строк и выводит подробную информацию о том, что происходит.
|
||
*/
|
||
void printDiagnosticInfo(Block & block, WriteBuffer & out);
|
||
|
||
void updateDiagnosticInfo()
|
||
{
|
||
++row_num;
|
||
|
||
bytes_read_at_start_of_buffer_on_prev_row = bytes_read_at_start_of_buffer_on_current_row;
|
||
bytes_read_at_start_of_buffer_on_current_row = istr.count() - istr.offset();
|
||
|
||
pos_of_prev_row = pos_of_current_row;
|
||
pos_of_current_row = istr.position();
|
||
}
|
||
|
||
bool parseRowAndPrintDiagnosticInfo(Block & block,
|
||
WriteBuffer & out, size_t max_length_of_column_name, size_t max_length_of_data_type_name);
|
||
};
|
||
|
||
}
|