2011-09-04 21:23:19 +00:00
|
|
|
#pragma once
|
2010-05-21 19:52:50 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Defines.h>
|
|
|
|
#include <DataStreams/IProfilingBlockInputStream.h>
|
2018-06-10 19:22:49 +00:00
|
|
|
#include <Formats/FormatSettings.h>
|
|
|
|
#include <Formats/IRowInputStream.h>
|
2010-05-21 19:52:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-01-27 04:29:47 +00:00
|
|
|
/** Makes block-oriented stream on top of row-oriented stream.
|
|
|
|
* It is used to read data from text formats.
|
|
|
|
*
|
|
|
|
* Also controls over parsing errors and prints diagnostic information about them.
|
2010-05-21 19:52:50 +00:00
|
|
|
*/
|
2011-09-04 21:23:19 +00:00
|
|
|
class BlockInputStreamFromRowInputStream : public IProfilingBlockInputStream
|
2010-05-21 19:52:50 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
/** sample_ - block with zero rows, that structure describes how to interpret values */
|
|
|
|
BlockInputStreamFromRowInputStream(
|
2017-09-08 03:47:27 +00:00
|
|
|
const RowInputStreamPtr & row_input_,
|
2017-04-01 07:20:54 +00:00
|
|
|
const Block & sample_,
|
|
|
|
size_t max_block_size_,
|
2018-06-10 19:22:49 +00:00
|
|
|
const FormatSettings & settings);
|
2010-05-21 19:52:50 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void readPrefix() override { row_input->readPrefix(); }
|
2018-07-18 19:02:40 +00:00
|
|
|
void readSuffix() override;
|
2011-09-04 21:23:19 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override { return "BlockInputStreamFromRowInputStream"; }
|
2010-05-21 19:52:50 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
RowInputStreamPtr & getRowInput() { return row_input; }
|
2015-03-29 07:13:38 +00:00
|
|
|
|
2018-02-18 03:23:48 +00:00
|
|
|
Block getHeader() const override { return sample; }
|
2018-01-06 18:10:44 +00:00
|
|
|
|
2018-12-04 14:09:47 +00:00
|
|
|
const BlockMissingValues & getMissingValues() const override { return block_missing_values; }
|
2018-11-15 15:57:20 +00:00
|
|
|
|
2012-10-20 02:10:47 +00:00
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
Block readImpl() override;
|
2012-10-20 02:10:47 +00:00
|
|
|
|
2010-05-21 19:52:50 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
RowInputStreamPtr row_input;
|
2017-12-18 02:43:40 +00:00
|
|
|
Block sample;
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t max_block_size;
|
2018-12-04 14:09:47 +00:00
|
|
|
BlockMissingValues block_missing_values;
|
2017-01-27 04:29:47 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
UInt64 allow_errors_num;
|
2019-01-07 19:56:53 +00:00
|
|
|
Float32 allow_errors_ratio;
|
2017-01-27 04:29:47 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t total_rows = 0;
|
|
|
|
size_t num_errors = 0;
|
2010-05-21 19:52:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|