ClickHouse/dbms/DataStreams/ExpressionBlockInputStream.h

54 lines
1.3 KiB
C++
Raw Normal View History

2011-08-14 00:49:30 +00:00
#pragma once
#include <DataStreams/IBlockInputStream.h>
2011-08-14 00:49:30 +00:00
namespace DB
{
2016-01-13 00:32:59 +00:00
class ExpressionActions;
2011-08-14 00:49:30 +00:00
2017-05-13 22:19:04 +00:00
/** Executes a certain expression over the block.
* The expression consists of column identifiers from the block, constants, common functions.
* For example: hits * 2 + 3, url LIKE '%yandex%'
* The expression processes each row independently of the others.
2011-08-14 00:49:30 +00:00
*/
class ExpressionBlockInputStream : public IBlockInputStream
2011-08-14 00:49:30 +00:00
{
public:
using ExpressionActionsPtr = std::shared_ptr<ExpressionActions>;
ExpressionBlockInputStream(const BlockInputStreamPtr & input, const ExpressionActionsPtr & expression_);
String getName() const override;
Block getTotals() override;
Block getHeader() const override;
2012-10-20 02:10:47 +00:00
protected:
bool initialized = false;
ExpressionActionsPtr expression;
Block readImpl() override;
2011-08-14 00:49:30 +00:00
private:
2019-05-16 17:16:25 +00:00
Block cached_header;
};
/// ExpressionBlockInputStream that could generate many out blocks for single input block.
2020-01-20 14:17:55 +00:00
class InflatingExpressionBlockInputStream : public ExpressionBlockInputStream
{
public:
2020-01-20 14:17:55 +00:00
InflatingExpressionBlockInputStream(const BlockInputStreamPtr & input, const ExpressionActionsPtr & expression_)
: ExpressionBlockInputStream(input, expression_)
{}
protected:
Block readImpl() override;
private:
2020-01-15 20:33:29 +00:00
ExtraBlockPtr not_processed;
size_t action_number = 0;
2011-08-14 00:49:30 +00:00
};
}