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-05-09 13:12:38 +00:00
|
|
|
AggregatingBlockInputStream::AggregatingBlockInputStream(BlockInputStreamPtr input_, ExpressionPtr expression)
|
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);
|
|
|
|
aggregator = new Aggregator(key_names, aggregates);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|