ClickHouse/dbms/src/DataStreams/MergingAggregatedBlockInputStream.h

41 lines
943 B
C++
Raw Normal View History

2012-05-08 11:19:00 +00:00
#pragma once
#include <Interpreters/Aggregator.h>
#include <DataStreams/IBlockInputStream.h>
2012-05-08 11:19:00 +00:00
namespace DB
{
2017-05-13 22:19:04 +00:00
/** A pre-aggregate stream of blocks in which each block is already aggregated.
* Aggregate functions in blocks should not be finalized so that their states can be merged.
2012-05-08 11:19:00 +00:00
*/
class MergingAggregatedBlockInputStream : public IBlockInputStream
2012-05-08 11:19:00 +00:00
{
public:
MergingAggregatedBlockInputStream(const BlockInputStreamPtr & input, const Aggregator::Params & params, bool final_, size_t max_threads_)
: aggregator(params), final(final_), max_threads(max_threads_)
{
children.push_back(input);
}
2012-05-08 11:19:00 +00:00
String getName() const override { return "MergingAggregated"; }
2012-05-08 11:19:00 +00:00
Block getHeader() const override;
2012-10-20 02:10:47 +00:00
protected:
Block readImpl() override;
2012-10-20 02:10:47 +00:00
2012-05-08 11:19:00 +00:00
private:
Aggregator aggregator;
bool final;
size_t max_threads;
bool executed = false;
BlocksList blocks;
BlocksList::iterator it;
2012-05-08 11:19:00 +00:00
};
}