1#pragma once
2#include <Processors/Transforms/SortingTransform.h>
3
4namespace DB
5{
6
7/** Takes stream already sorted by `x` and finishes sorting it by (`x`, `y`).
8 * During sorting only chunks with rows that equal by `x` saved in RAM.
9 * */
10class FinishSortingTransform : public SortingTransform
11{
12public:
13 /// limit - if not 0, allowed to return just first 'limit' rows in sorted order.
14 FinishSortingTransform(const Block & header, const SortDescription & description_sorted_,
15 const SortDescription & description_to_sort_,
16 size_t max_merged_block_size_, UInt64 limit_);
17
18 String getName() const override { return "FinishSortingTransform"; }
19
20protected:
21 void consume(Chunk chunk) override;
22 void generate() override;
23
24private:
25 SortDescription description_sorted;
26
27 Chunk tail_chunk;
28};
29
30}
31