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
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/** Преобразует поток для чтения данных по строкам в поток для чтения данных по блокам.
|
|
|
|
|
* Наример, для чтения текстового дампа.
|
|
|
|
|
*/
|
2011-09-04 21:23:19 +00:00
|
|
|
|
class BlockInputStreamFromRowInputStream : public IProfilingBlockInputStream
|
2010-05-21 19:52:50 +00:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/** sample_ - пустой блок, который описывает, как интерпретировать значения */
|
|
|
|
|
BlockInputStreamFromRowInputStream(
|
2011-10-24 12:10:59 +00:00
|
|
|
|
RowInputStreamPtr row_input_,
|
2010-05-21 19:52:50 +00:00
|
|
|
|
const Block & sample_,
|
2014-04-29 20:22:57 +00:00
|
|
|
|
size_t max_block_size_ = DEFAULT_INSERT_BLOCK_SIZE); /// Обычно дамп читается в целях вставки в таблицу.
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2012-12-29 15:41:17 +00:00
|
|
|
|
size_t total_rows;
|
2010-05-21 19:52:50 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|