| 264 | } |
| 265 | |
| 266 | void WindowStep::scatterByPartitionIfNeeded(QueryPipeline& pipeline) |
| 267 | { |
| 268 | size_t threads = pipeline.getNumThreads(); |
| 269 | size_t streams = pipeline.getNumStreams(); |
| 270 | |
| 271 | if (!window_description.partition_by.empty() && threads > 1) |
| 272 | { |
| 273 | Block stream_header = pipeline.getHeader(); |
| 274 | |
| 275 | ColumnNumbers key_columns; |
| 276 | key_columns.reserve(window_description.partition_by.size()); |
| 277 | for (auto & col : window_description.partition_by) |
| 278 | { |
| 279 | key_columns.push_back(stream_header.getPositionByName(col.column_name)); |
| 280 | } |
| 281 | |
| 282 | pipeline.transform([&](OutputPortRawPtrs ports) |
| 283 | { |
| 284 | Processors processors; |
| 285 | for (auto * port : ports) |
| 286 | { |
| 287 | auto scatter = std::make_shared<ScatterByPartitionTransform>(stream_header, threads, key_columns); |
| 288 | connect(*port, scatter->getInputs().front()); |
| 289 | processors.push_back(scatter); |
| 290 | } |
| 291 | return processors; |
| 292 | }); |
| 293 | |
| 294 | if (streams > 1) |
| 295 | { |
| 296 | pipeline.transform([&](OutputPortRawPtrs ports) |
| 297 | { |
| 298 | Processors processors; |
| 299 | for (size_t i = 0; i < threads; ++i) |
| 300 | { |
| 301 | size_t output_it = i; |
| 302 | auto resize = std::make_shared<ResizeProcessor>(ports[output_it]->getHeader(), streams, 1); |
| 303 | auto & inputs = resize->getInputs(); |
| 304 | |
| 305 | for (auto input_it = inputs.begin(); input_it != inputs.end(); output_it += threads, ++input_it) |
| 306 | connect(*ports[output_it], *input_it); |
| 307 | processors.push_back(resize); |
| 308 | } |
| 309 | return processors; |
| 310 | }); |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | } |
nothing calls this directly
no test coverage detected