ClickHouse/dbms/src/DataStreams/MergingAggregatedBlockInputStream.h

48 lines
1.1 KiB
C++
Raw Normal View History

2012-05-08 11:19:00 +00:00
#pragma once
#include <Interpreters/Aggregator.h>
#include <DataStreams/IProfilingBlockInputStream.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
*/
2012-05-30 01:38:02 +00:00
class MergingAggregatedBlockInputStream : public IProfilingBlockInputStream
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
String getID() const override
{
std::stringstream res;
res << "MergingAggregated(" << children.back()->getID() << ", " << aggregator.getID() << ")";
return res.str();
}
Block getHeader() 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
};
}