1 | #pragma once |
---|---|
2 | #include <Core/SortDescription.h> |
3 | #include <Columns/IColumn.h> |
4 | #include <Common/FieldVisitors.h> |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | /// Compares fields in terms of sorting order, considering direction. |
10 | bool less(const Field & lhs, const Field & rhs, int direction); |
11 | bool equals(const Field & lhs, const Field & rhs); |
12 | |
13 | /** Helps to implement modifier WITH FILL for ORDER BY clause. |
14 | * Stores row as array of fields and provides functions to generate next row for filling gaps and for comparing rows. |
15 | * Used in FillingBlockInputStream and in FillingTransform. |
16 | */ |
17 | class FillingRow |
18 | { |
19 | public: |
20 | FillingRow(const SortDescription & sort_description); |
21 | |
22 | /// Generates next row according to fill 'from', 'to' and 'step' values. |
23 | bool next(const FillingRow & to_row); |
24 | |
25 | void initFromDefaults(size_t from_pos = 0); |
26 | |
27 | Field & operator[](size_t ind) { return row[ind]; } |
28 | const Field & operator[](size_t ind) const { return row[ind]; } |
29 | size_t size() const { return row.size(); } |
30 | bool operator<(const FillingRow & other) const; |
31 | bool operator==(const FillingRow & other) const; |
32 | |
33 | int getDirection(size_t ind) const { return description[ind].direction; } |
34 | FillColumnDescription & getFillDescription(size_t ind) { return description[ind].fill_description; } |
35 | |
36 | private: |
37 | std::vector<Field> row; |
38 | SortDescription description; |
39 | }; |
40 | |
41 | void insertFromFillingRow(MutableColumns & filling_columns, MutableColumns & other_columns, const FillingRow & filling_row); |
42 | void copyRowFromColumns(MutableColumns & dest, const Columns & source, size_t row_num); |
43 | |
44 | } |
45 |