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-26 11:44:54 +00:00
|
|
|
bool overflow_row_, bool final_, size_t max_rows_to_group_by_, OverflowMode group_by_overflow_mode_)
|
|
|
|
: 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
|
|
|
|
2014-02-26 11:44:54 +00:00
|
|
|
aggregator = new Aggregator(key_names, aggregates, overflow_row_, 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();
|
|
|
|
|
2014-02-26 11:44:54 +00:00
|
|
|
return aggregator->convertToBlock(data_variants, final);
|
2011-09-19 03:34:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|