2011-09-04 21:23:19 +00:00
|
|
|
#pragma once
|
2010-05-21 19:52:50 +00:00
|
|
|
|
|
|
|
#include <DB/Core/Defines.h>
|
2011-09-04 21:23:19 +00:00
|
|
|
#include <DB/DataStreams/IProfilingBlockInputStream.h>
|
2010-05-21 19:52:50 +00:00
|
|
|
#include <DB/DataStreams/IRowInputStream.h>
|
|
|
|
|
|
|
|
|
|
|
|
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-01-27 04:29:47 +00:00
|
|
|
/** sample_ - block with zero rows, that structure describes how to interpret values */
|
2010-05-21 19:52:50 +00:00
|
|
|
BlockInputStreamFromRowInputStream(
|
2011-10-24 12:10:59 +00:00
|
|
|
RowInputStreamPtr row_input_,
|
2010-05-21 19:52:50 +00:00
|
|
|
const Block & sample_,
|
2017-01-27 04:29:47 +00:00
|
|
|
size_t max_block_size_,
|
|
|
|
UInt64 allow_errors_num_,
|
|
|
|
Float64 allow_errors_ratio_);
|
2010-05-21 19:52:50 +00:00
|
|
|
|
2014-11-08 23:52:18 +00:00
|
|
|
void readPrefix() override { row_input->readPrefix(); }
|
|
|
|
void readSuffix() override { row_input->readSuffix(); }
|
2011-09-04 21:23:19 +00:00
|
|
|
|
2014-11-08 23:52:18 +00:00
|
|
|
String getName() const override { return "BlockInputStreamFromRowInputStream"; }
|
2010-05-21 19:52:50 +00:00
|
|
|
|
2014-11-08 23:52:18 +00:00
|
|
|
String getID() const override
|
2013-05-03 10:20:53 +00:00
|
|
|
{
|
|
|
|
std::stringstream res;
|
|
|
|
res << this;
|
|
|
|
return res.str();
|
|
|
|
}
|
|
|
|
|
2015-03-29 07:13:38 +00:00
|
|
|
RowInputStreamPtr & getRowInput() { return row_input; }
|
|
|
|
|
2012-10-20 02:10:47 +00:00
|
|
|
protected:
|
2014-11-08 23:52:18 +00:00
|
|
|
Block readImpl() override;
|
2012-10-20 02:10:47 +00:00
|
|
|
|
2010-05-21 19:52:50 +00:00
|
|
|
private:
|
2011-10-24 12:10:59 +00:00
|
|
|
RowInputStreamPtr row_input;
|
2012-10-10 18:32:45 +00:00
|
|
|
const Block sample;
|
2010-05-21 19:52:50 +00:00
|
|
|
size_t max_block_size;
|
2017-01-27 04:29:47 +00:00
|
|
|
|
|
|
|
UInt64 allow_errors_num;
|
|
|
|
Float64 allow_errors_ratio;
|
|
|
|
|
|
|
|
size_t total_rows = 0;
|
|
|
|
size_t num_errors = 0;
|
2010-05-21 19:52:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|