ClickHouse/dbms/include/DB/DataStreams/MergingAggregatedBlockInputStream.h

48 lines
1.2 KiB
C
Raw Normal View History

2012-05-08 11:19:00 +00:00
#pragma once
#include <DB/Interpreters/Aggregator.h>
#include <DB/DataStreams/IProfilingBlockInputStream.h>
namespace DB
{
using Poco::SharedPtr;
2012-05-30 01:38:02 +00:00
/** Доагрегирует поток блоков, в котором каждый блок уже агрегирован.
* Агрегатные функции в блоках не должны быть финализированы, чтобы их состояния можно было объединить.
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(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();
}
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
};
}