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>
|
|
|
|
#include <DataStreams/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_,
|
|
|
|
UInt64 allow_errors_num_,
|
|
|
|
Float64 allow_errors_ratio_);
|
2010-05-21 19:52:50 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void readPrefix() override { row_input->readPrefix(); }
|
|
|
|
void readSuffix() override { row_input->readSuffix(); }
|
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
|
|
|
|
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;
|
2017-01-27 04:29:47 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
UInt64 allow_errors_num;
|
|
|
|
Float64 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
|
|
|
};
|
|
|
|
|
|
|
|
}
|