ClickHouse/dbms/include/DB/DataStreams/MaterializingBlockInputStream.h

51 lines
1.0 KiB
C
Raw Normal View History

2011-11-06 06:22:52 +00:00
#pragma once
#include <DB/Columns/ColumnConst.h>
#include <DB/DataStreams/IProfilingBlockInputStream.h>
namespace DB
{
/** Преобразует столбцы-константы в полноценные столбцы ("материализует" их).
*/
class MaterializingBlockInputStream : public IProfilingBlockInputStream
{
public:
MaterializingBlockInputStream(BlockInputStreamPtr input_)
{
2013-05-04 04:05:15 +00:00
children.push_back(input_);
2011-11-06 06:22:52 +00:00
}
String getName() const override { return "Materializing"; }
2012-10-20 02:10:47 +00:00
String getID() const override
{
std::stringstream res;
2013-05-04 05:20:07 +00:00
res << "Materializing(" << children.back()->getID() << ")";
return res.str();
}
2012-10-20 02:10:47 +00:00
protected:
Block readImpl() override
2011-11-06 06:22:52 +00:00
{
2013-05-04 05:20:07 +00:00
Block res = children.back()->read();
2011-11-06 06:22:52 +00:00
if (!res)
return res;
size_t columns = res.columns();
for (size_t i = 0; i < columns; ++i)
{
ColumnPtr col = res.getByPosition(i).column;
if (col->isConst())
res.getByPosition(i).column = dynamic_cast<IColumnConst &>(*col).convertToFullColumn();
}
return res;
}
};
}