ClickHouse/src/Processors/Merges/SummingSortedTransform.h

38 lines
1.2 KiB
C++
Raw Normal View History

2020-03-31 14:11:58 +00:00
#pragma once
#include <Processors/Merges/IMergingTransform.h>
2020-04-13 18:51:17 +00:00
#include <Processors/Merges/SummingSortedAlgorithm.h>
2020-03-31 14:11:58 +00:00
namespace DB
{
2020-04-06 19:27:50 +00:00
/** Merges several sorted ports into one.
* For each group of consecutive identical values of the primary key (the columns by which the data is sorted),
* collapses them into one row, summing all the numeric columns except the primary key.
* If in all numeric columns, except for the primary key, the result is zero, it deletes the row.
*/
2020-04-13 18:51:17 +00:00
class SummingSortedTransform final : public IMergingTransform2<SummingSortedAlgorithm>
2020-03-31 14:11:58 +00:00
{
2020-04-01 18:00:26 +00:00
public:
2020-03-31 14:11:58 +00:00
2020-04-01 18:00:26 +00:00
SummingSortedTransform(
2020-04-02 16:28:50 +00:00
const Block & header, size_t num_inputs,
2020-04-01 18:00:26 +00:00
SortDescription description_,
/// List of columns to be summed. If empty, all numeric columns that are not in the description are taken.
const Names & column_names_to_sum,
2020-04-13 18:51:17 +00:00
size_t max_block_size)
: IMergingTransform2(
num_inputs, header, header, true,
header,
num_inputs,
std::move(description_),
column_names_to_sum,
max_block_size)
2020-03-31 14:11:58 +00:00
{
2020-04-13 18:51:17 +00:00
}
2020-03-31 14:11:58 +00:00
2020-04-01 11:45:02 +00:00
String getName() const override { return "SummingSortedTransform"; }
2020-03-31 14:11:58 +00:00
};
}