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
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2013-08-30 19:21:40 +00:00
|
|
|
AggregatingBlockInputStream::AggregatingBlockInputStream(BlockInputStreamPtr input_,
|
|
|
|
const Names & key_names, const AggregateDescriptions & aggregates,
|
2014-02-17 23:56:45 +00:00
|
|
|
bool with_totals_, bool separate_totals_, bool final_, size_t max_rows_to_group_by_, OverflowMode group_by_overflow_mode_)
|
2013-11-03 23:35:18 +00:00
|
|
|
: separate_totals(separate_totals_), final(final_), has_been_read(false)
|
2011-09-24 20:32:41 +00:00
|
|
|
{
|
2013-05-04 04:05:15 +00:00
|
|
|
children.push_back(input_);
|
2011-09-24 20:32:41 +00:00
|
|
|
|
2013-05-04 15:46:50 +00:00
|
|
|
aggregator = new Aggregator(key_names, aggregates, with_totals_, 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;
|
2013-05-04 05:20:07 +00:00
|
|
|
|
2011-09-26 07:25:22 +00:00
|
|
|
AggregatedDataVariants data_variants;
|
2013-05-04 05:20:07 +00:00
|
|
|
aggregator->execute(children.back(), data_variants);
|
2013-01-07 01:41:06 +00:00
|
|
|
|
|
|
|
if (isCancelled())
|
|
|
|
return Block();
|
|
|
|
|
2013-11-03 23:35:18 +00:00
|
|
|
return aggregator->convertToBlock(data_variants, separate_totals, totals, final);
|
2011-09-19 03:34:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|