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_,
|
|
|
|
|
size_t max_block_size_ = DEFAULT_BLOCK_SIZE);
|
|
|
|
|
|
2011-11-06 06:22:52 +00:00
|
|
|
|
void readPrefix() { row_input->readPrefix(); }
|
|
|
|
|
void readSuffix() { row_input->readSuffix(); }
|
2011-09-04 21:23:19 +00:00
|
|
|
|
|
|
|
|
|
String getName() const { return "BlockInputStreamFromRowInputStream"; }
|
2010-05-21 19:52:50 +00:00
|
|
|
|
|
2013-05-03 10:20:53 +00:00
|
|
|
|
String getID() const
|
|
|
|
|
{
|
|
|
|
|
std::stringstream res;
|
|
|
|
|
res << this;
|
|
|
|
|
return res.str();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-20 02:10:47 +00:00
|
|
|
|
protected:
|
|
|
|
|
Block readImpl();
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|