1 | #pragma once |
---|---|
2 | |
3 | #include <Core/SortDescription.h> |
4 | |
5 | #include <DataStreams/IBlockInputStream.h> |
6 | |
7 | |
8 | namespace DB |
9 | { |
10 | |
11 | /** Sorts each block individually by the values of the specified columns. |
12 | * At the moment, not very optimal algorithm is used. |
13 | */ |
14 | class PartialSortingBlockInputStream : public IBlockInputStream |
15 | { |
16 | public: |
17 | /// limit - if not 0, then you can sort each block not completely, but only `limit` first rows by order. |
18 | PartialSortingBlockInputStream(const BlockInputStreamPtr & input_, SortDescription & description_, UInt64 limit_ = 0) |
19 | : description(description_), limit(limit_) |
20 | { |
21 | children.push_back(input_); |
22 | } |
23 | |
24 | String getName() const override { return "PartialSorting"; } |
25 | Block getHeader() const override { return children.at(0)->getHeader(); } |
26 | |
27 | protected: |
28 | Block readImpl() override; |
29 | |
30 | private: |
31 | SortDescription description; |
32 | UInt64 limit; |
33 | }; |
34 | |
35 | } |
36 |