mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
73 lines
1.5 KiB
C++
73 lines
1.5 KiB
C++
#include <Interpreters/ExpressionActions.h>
|
|
#include <DataStreams/ExpressionBlockInputStream.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
ExpressionBlockInputStream::ExpressionBlockInputStream(const BlockInputStreamPtr & input, const ExpressionActionsPtr & expression_)
|
|
: expression(expression_)
|
|
{
|
|
children.push_back(input);
|
|
cached_header = children.back()->getHeader();
|
|
expression->execute(cached_header, true);
|
|
}
|
|
|
|
String ExpressionBlockInputStream::getName() const { return "Expression"; }
|
|
|
|
Block ExpressionBlockInputStream::getTotals()
|
|
{
|
|
totals = children.back()->getTotals();
|
|
expression->executeOnTotals(totals);
|
|
|
|
return totals;
|
|
}
|
|
|
|
Block ExpressionBlockInputStream::getHeader() const
|
|
{
|
|
return cached_header.cloneEmpty();
|
|
}
|
|
|
|
Block ExpressionBlockInputStream::readImpl()
|
|
{
|
|
if (!initialized)
|
|
{
|
|
if (expression->resultIsAlwaysEmpty())
|
|
return {};
|
|
|
|
initialized = true;
|
|
}
|
|
|
|
Block res = children.back()->read();
|
|
if (res)
|
|
expression->execute(res);
|
|
return res;
|
|
}
|
|
|
|
Block InflatingExpressionBlockInputStream::readImpl()
|
|
{
|
|
if (!initialized)
|
|
{
|
|
if (expression->resultIsAlwaysEmpty())
|
|
return {};
|
|
|
|
initialized = true;
|
|
}
|
|
|
|
Block res;
|
|
if (likely(!not_processed))
|
|
{
|
|
res = children.back()->read();
|
|
if (res)
|
|
expression->execute(res, not_processed, action_number);
|
|
}
|
|
else
|
|
{
|
|
res = std::move(not_processed->block);
|
|
expression->execute(res, not_processed, action_number);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
}
|