2012-05-08 11:19:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Interpreters/Aggregator.h>
|
2019-01-23 14:48:50 +00:00
|
|
|
#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
|
|
|
*/
|
2019-01-23 14:48:50 +00:00
|
|
|
class MergingAggregatedBlockInputStream : public IBlockInputStream
|
2012-05-08 11:19:00 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-09-08 02:29:47 +00:00
|
|
|
MergingAggregatedBlockInputStream(const BlockInputStreamPtr & input, const Aggregator::Params & params, bool final_, size_t max_threads_)
|
2017-04-01 07:20:54 +00:00
|
|
|
: aggregator(params), final(final_), max_threads(max_threads_)
|
|
|
|
{
|
2017-09-08 02:29:47 +00:00
|
|
|
children.push_back(input);
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2012-05-08 11:19:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override { return "MergingAggregated"; }
|
2012-05-08 11:19:00 +00:00
|
|
|
|
2018-02-18 03:23:48 +00:00
|
|
|
Block getHeader() const override;
|
2018-01-06 18:10:44 +00:00
|
|
|
|
2012-10-20 02:10:47 +00:00
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
Block readImpl() override;
|
2012-10-20 02:10:47 +00:00
|
|
|
|
2012-05-08 11:19:00 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
Aggregator aggregator;
|
|
|
|
bool final;
|
|
|
|
size_t max_threads;
|
2015-01-02 03:16:28 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
bool executed = false;
|
|
|
|
BlocksList blocks;
|
|
|
|
BlocksList::iterator it;
|
2012-05-08 11:19:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|