2011-08-14 00:49:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-23 14:48:50 +00:00
|
|
|
#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
|
|
|
*/
|
2019-01-23 14:48:50 +00:00
|
|
|
class ExpressionBlockInputStream : public IBlockInputStream
|
2011-08-14 00:49:30 +00:00
|
|
|
{
|
2020-01-13 18:00:32 +00:00
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
using ExpressionActionsPtr = std::shared_ptr<ExpressionActions>;
|
2013-05-03 10:20:53 +00:00
|
|
|
|
2017-09-08 03:47:27 +00:00
|
|
|
ExpressionBlockInputStream(const BlockInputStreamPtr & input, const ExpressionActionsPtr & expression_);
|
2013-09-08 08:27:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override;
|
2018-02-23 10:43:24 +00:00
|
|
|
Block getTotals() override;
|
2018-02-18 03:23:48 +00:00
|
|
|
Block getHeader() const override;
|
2013-09-08 08:27:06 +00:00
|
|
|
|
2012-10-20 02:10:47 +00:00
|
|
|
protected:
|
2020-01-13 18:00:32 +00:00
|
|
|
bool initialized = false;
|
|
|
|
ExpressionActionsPtr expression;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Block readImpl() override;
|
2011-08-14 00:49:30 +00:00
|
|
|
|
|
|
|
private:
|
2019-05-16 17:16:25 +00:00
|
|
|
Block cached_header;
|
2020-01-13 18:00:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// ExpressionBlockInputStream that could generate many out blocks for single input block.
|
2020-01-20 14:17:55 +00:00
|
|
|
class InflatingExpressionBlockInputStream : public ExpressionBlockInputStream
|
2020-01-13 18:00:32 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-01-20 14:17:55 +00:00
|
|
|
InflatingExpressionBlockInputStream(const BlockInputStreamPtr & input, const ExpressionActionsPtr & expression_)
|
2020-01-13 18:00:32 +00:00
|
|
|
: ExpressionBlockInputStream(input, expression_)
|
|
|
|
{}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Block readImpl() override;
|
|
|
|
|
|
|
|
private:
|
2020-01-15 20:33:29 +00:00
|
|
|
ExtraBlockPtr not_processed;
|
2020-01-13 18:00:32 +00:00
|
|
|
size_t action_number = 0;
|
2011-08-14 00:49:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|