| 185 | |
| 186 | |
| 187 | SortingTransform::SortingTransform( |
| 188 | SharedHeader header, |
| 189 | const SortDescription & description_, |
| 190 | size_t max_merged_block_size_, |
| 191 | UInt64 limit_, |
| 192 | bool increase_sort_description_compile_attempts) |
| 193 | : IProcessor({header}, {header}) |
| 194 | , description(description_) |
| 195 | , max_merged_block_size(max_merged_block_size_) |
| 196 | , limit(limit_) |
| 197 | { |
| 198 | const auto & sample = inputs.front().getHeader(); |
| 199 | |
| 200 | /// Remove constants from header and map old indexes to new. |
| 201 | size_t num_columns = sample.columns(); |
| 202 | ColumnNumbers map(num_columns, num_columns); |
| 203 | const_columns_to_remove.assign(num_columns, true); |
| 204 | for (size_t pos = 0; pos < num_columns; ++pos) |
| 205 | { |
| 206 | const auto & column = sample.getByPosition(pos); |
| 207 | if (!(column.column && isColumnConst(*column.column))) |
| 208 | { |
| 209 | map[pos] = header_without_constants.columns(); |
| 210 | header_without_constants.insert(column); |
| 211 | const_columns_to_remove[pos] = false; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | DataTypes sort_description_types; |
| 216 | sort_description_types.reserve(description.size()); |
| 217 | |
| 218 | /// Remove constants from column_description and remap positions. |
| 219 | SortDescription description_without_constants; |
| 220 | description_without_constants.reserve(description.size()); |
| 221 | for (const auto & column_description : description) |
| 222 | { |
| 223 | auto old_pos = header->getPositionByName(column_description.column_name); |
| 224 | auto new_pos = map[old_pos]; |
| 225 | |
| 226 | if (new_pos < num_columns) |
| 227 | { |
| 228 | sort_description_types.emplace_back(sample.safeGetByPosition(old_pos).type); |
| 229 | description_without_constants.push_back(column_description); |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | description.swap(description_without_constants); |
| 234 | |
| 235 | if (SortQueueVariants(sort_description_types, description).variantSupportJITCompilation()) |
| 236 | compileSortDescriptionIfNeeded(description, sort_description_types, increase_sort_description_compile_attempts /*increase_compile_attempts*/); |
| 237 | } |
| 238 | |
| 239 | SortingTransform::~SortingTransform() = default; |
| 240 |
nothing calls this directly
no test coverage detected