ClickHouse/dbms/src/DataStreams/ExpressionBlockInputStream.cpp

46 lines
975 B
C++
Raw Normal View History

2016-01-13 00:32:59 +00:00
#include <DB/Interpreters/ExpressionActions.h>
#include <DB/DataStreams/ExpressionBlockInputStream.h>
namespace DB
{
ExpressionBlockInputStream::ExpressionBlockInputStream(BlockInputStreamPtr input_, ExpressionActionsPtr expression_)
: expression(expression_)
{
children.push_back(input_);
}
String ExpressionBlockInputStream::getName() const { return "Expression"; }
String ExpressionBlockInputStream::getID() const
{
std::stringstream res;
res << "Expression(" << children.back()->getID() << ", " << expression->getID() << ")";
return res.str();
}
const Block & ExpressionBlockInputStream::getTotals()
{
if (IProfilingBlockInputStream * child = dynamic_cast<IProfilingBlockInputStream *>(&*children.back()))
{
totals = child->getTotals();
expression->executeOnTotals(totals);
}
return totals;
}
Block ExpressionBlockInputStream::readImpl()
{
Block res = children.back()->read();
if (!res)
return res;
expression->execute(res);
return res;
}
}