| 2344 | // |
| 2345 | |
| 2346 | void Optimizer::findDependentStreams(const RiverList& rivers, |
| 2347 | const StreamList& streams, |
| 2348 | StreamList& dependentStreams, |
| 2349 | StreamList& freeStreams) |
| 2350 | { |
| 2351 | #ifdef OPT_DEBUG_RETRIEVAL |
| 2352 | if (streams.hasData()) |
| 2353 | printf("Detecting dependent streams:\n"); |
| 2354 | #endif |
| 2355 | |
| 2356 | for (const auto stream : streams) |
| 2357 | { |
| 2358 | const auto tail = &csb->csb_rpt[stream]; |
| 2359 | |
| 2360 | // Set temporary active flag for this stream |
| 2361 | tail->activate(); |
| 2362 | |
| 2363 | bool dependent = false; |
| 2364 | |
| 2365 | if (conjuncts.hasData()) |
| 2366 | { |
| 2367 | // Calculate the inversion for this stream. |
| 2368 | // The returning candidate contains the streams that will be used for |
| 2369 | // index retrieval. This meant that if some stream is used this stream |
| 2370 | // depends on already active streams and can not be used in a separate |
| 2371 | // SORT/MERGE. |
| 2372 | |
| 2373 | Retrieval retrieval(tdbb, this, stream, false, false, nullptr, true); |
| 2374 | const auto candidate = retrieval.getInversion(); |
| 2375 | |
| 2376 | if (candidate->dependentFromStreams.hasData()) |
| 2377 | { |
| 2378 | dependent = true; |
| 2379 | |
| 2380 | StreamList checkStreams; |
| 2381 | checkStreams.add(stream); |
| 2382 | |
| 2383 | for (const auto river : rivers) |
| 2384 | { |
| 2385 | // If some river already depends on this stream, |
| 2386 | // then itself it cannot be dependent |
| 2387 | if (river->isDependent(checkStreams)) |
| 2388 | { |
| 2389 | dependent = false; |
| 2390 | break; |
| 2391 | } |
| 2392 | } |
| 2393 | } |
| 2394 | } |
| 2395 | |
| 2396 | if (dependent) |
| 2397 | dependentStreams.add(stream); |
| 2398 | else |
| 2399 | freeStreams.add(stream); |
| 2400 | |
| 2401 | // Reset active flag |
| 2402 | tail->deactivate(); |
| 2403 | } |
nothing calls this directly
no test coverage detected