| 1 | #pragma once | 
|---|
| 2 | #include <Processors/Transforms/SortingTransform.h> | 
|---|
| 3 |  | 
|---|
| 4 | namespace 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 | * */ | 
|---|
| 10 | class FinishSortingTransform : public SortingTransform | 
|---|
| 11 | { | 
|---|
| 12 | public: | 
|---|
| 13 | /// limit - if not 0, allowed to return just first 'limit' rows in sorted order. | 
|---|
| 14 | FinishSortingTransform(const Block & , 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 |  | 
|---|
| 20 | protected: | 
|---|
| 21 | void consume(Chunk chunk) override; | 
|---|
| 22 | void generate() override; | 
|---|
| 23 |  | 
|---|
| 24 | private: | 
|---|
| 25 | SortDescription description_sorted; | 
|---|
| 26 |  | 
|---|
| 27 | Chunk tail_chunk; | 
|---|
| 28 | }; | 
|---|
| 29 |  | 
|---|
| 30 | } | 
|---|
| 31 |  | 
|---|