blob: e9fa0818779a79a8c52c36bda2ea2cbcfbb2a1c0 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#pragma once
#include <memory>
#include <Core/ColumnNumbers.h>
#include <Processors/IAccumulatingTransform.h>
#include <Processors/Transforms/AggregatingTransform.h>
#include <Processors/Transforms/finalizeChunk.h>
namespace DB
{
struct GroupByModifierTransform : public IAccumulatingTransform
{
GroupByModifierTransform(Block header, AggregatingTransformParamsPtr params_, bool use_nulls_);
protected:
void consume(Chunk chunk) override;
void mergeConsumed();
Chunk merge(Chunks && chunks, bool is_input, bool final);
MutableColumnPtr getColumnWithDefaults(size_t key, size_t n) const;
AggregatingTransformParamsPtr params;
bool use_nulls;
ColumnNumbers keys;
std::unique_ptr<Aggregator> output_aggregator;
Block intermediate_header;
Chunks consumed_chunks;
Chunk current_chunk;
};
/// Takes blocks after grouping, with non-finalized aggregate functions.
/// Calculates subtotals and grand totals values for a set of columns.
class RollupTransform : public GroupByModifierTransform
{
public:
RollupTransform(Block header, AggregatingTransformParamsPtr params, bool use_nulls_);
String getName() const override { return "RollupTransform"; }
protected:
Chunk generate() override;
private:
const ColumnsMask aggregates_mask;
size_t last_removed_key = 0;
size_t set_counter = 0;
};
}
|