2011-09-26 11:49:39 +00:00
|
|
|
#include <DB/Columns/ColumnsNumber.h>
|
|
|
|
|
2011-09-19 03:34:23 +00:00
|
|
|
#include <DB/DataStreams/AggregatingBlockInputStream.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2012-12-25 19:28:59 +00:00
|
|
|
AggregatingBlockInputStream::AggregatingBlockInputStream(BlockInputStreamPtr input_, ExpressionPtr expression,
|
|
|
|
size_t max_rows_to_group_by_, Limits::OverflowMode group_by_overflow_mode_)
|
2011-09-24 20:32:41 +00:00
|
|
|
: input(input_), has_been_read(false)
|
|
|
|
{
|
|
|
|
children.push_back(input);
|
|
|
|
|
2011-09-25 03:37:09 +00:00
|
|
|
Names key_names;
|
|
|
|
AggregateDescriptions aggregates;
|
|
|
|
expression->getAggregateInfo(key_names, aggregates);
|
2012-12-25 19:28:59 +00:00
|
|
|
aggregator = new Aggregator(key_names, aggregates, max_rows_to_group_by_, group_by_overflow_mode_);
|
2011-09-25 03:37:09 +00:00
|
|
|
}
|
2011-09-24 20:32:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-19 03:34:23 +00:00
|
|
|
Block AggregatingBlockInputStream::readImpl()
|
|
|
|
{
|
|
|
|
if (has_been_read)
|
|
|
|
return Block();
|
|
|
|
|
|
|
|
has_been_read = true;
|
|
|
|
|
2011-09-26 07:25:22 +00:00
|
|
|
AggregatedDataVariants data_variants;
|
|
|
|
aggregator->execute(input, data_variants);
|
2012-02-27 06:28:20 +00:00
|
|
|
return aggregator->convertToBlock(data_variants);
|
2011-09-19 03:34:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|