MCPcopy Create free account
hub / github.com/ByConity/ByConity / scatterByPartitionIfNeeded

Method scatterByPartitionIfNeeded

src/QueryPlan/WindowStep.cpp:266–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264}
265
266void 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}

Callers

nothing calls this directly

Calls 13

connectFunction · 0.85
getNumThreadsMethod · 0.80
getNumStreamsMethod · 0.80
frontMethod · 0.80
emptyMethod · 0.45
getHeaderMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
getPositionByNameMethod · 0.45
transformMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected