aboutsummaryrefslogtreecommitdiffstats
path: root/ydb/library/arrow_clickhouse/DataStreams/MergingAggregatedBlockInputStream.cpp
blob: 2bd14e1371aa1bc59e6628dae3828066725b8261 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// The code in this file is based on original ClickHouse source code
// which is licensed under Apache license v2.0
// See: https://github.com/ClickHouse/ClickHouse/

#include <DataStreams/MergingAggregatedBlockInputStream.h>


namespace CH
{

Header MergingAggregatedBlockInputStream::getHeader() const
{
    return aggregator.getHeader(final);
}


Block MergingAggregatedBlockInputStream::readImpl()
{
    if (!executed)
    {
        executed = true;
        AggregatedDataVariants data_variants;
#if 0
        Aggregator::CancellationHook hook = [&]() { return this->isCancelled(); };
        aggregator.setCancellationHook(hook);
#endif
        aggregator.mergeStream(children.back(), data_variants);
        blocks = aggregator.convertToBlocks(data_variants, final);
        it = blocks.begin();
    }

    Block res;
    if (isCancelledOrThrowIfKilled() || it == blocks.end())
        return res;

    res = std::move(*it);
    ++it;

    return res;
}


}