ClickHouse/dbms/DataStreams/FilterBlockInputStream.h

47 lines
1.2 KiB
C++
Raw Normal View History

2011-08-22 20:37:21 +00:00
#pragma once
#include <DataStreams/IBlockInputStream.h>
#include <Columns/FilterDescription.h>
2011-08-22 20:37:21 +00:00
namespace DB
{
class ExpressionActions;
2011-08-22 20:37:21 +00:00
2017-05-13 22:19:04 +00:00
/** Implements WHERE, HAVING operations.
* A stream of blocks and an expression, which adds to the block one ColumnUInt8 column containing the filtering conditions, are passed as input.
* The expression is evaluated and a stream of blocks is returned, which contains only the filtered rows.
2011-08-22 20:37:21 +00:00
*/
class FilterBlockInputStream : public IBlockInputStream
2011-08-22 20:37:21 +00:00
{
private:
using ExpressionActionsPtr = std::shared_ptr<ExpressionActions>;
2011-08-22 20:37:21 +00:00
public:
2019-10-11 17:27:54 +00:00
FilterBlockInputStream(const BlockInputStreamPtr & input, ExpressionActionsPtr expression_,
String filter_column_name_, bool remove_filter_ = false);
2011-09-04 21:23:19 +00:00
String getName() const override;
Block getTotals() override;
Block getHeader() const override;
2012-10-20 02:10:47 +00:00
protected:
Block readImpl() override;
2012-10-20 02:10:47 +00:00
2018-04-16 12:21:36 +00:00
bool remove_filter;
2011-08-22 20:37:21 +00:00
private:
ExpressionActionsPtr expression;
Block header;
2019-10-11 17:27:54 +00:00
String filter_column_name;
ssize_t filter_column;
ConstantFilterDescription constant_filter_description;
2018-04-12 09:45:24 +00:00
Block removeFilterIfNeed(Block && block);
2011-08-22 20:37:21 +00:00
};
}