| 2230 | // |
| 2231 | |
| 2232 | InversionCandidate* Retrieval::matchOnIndexes(IndexScratchList& inputIndexScratches, |
| 2233 | BoolExprNode* boolean, |
| 2234 | unsigned scope) const |
| 2235 | { |
| 2236 | const auto binaryNode = nodeAs<BinaryBoolNode>(boolean); |
| 2237 | |
| 2238 | // Handle the "OR" case up front |
| 2239 | if (binaryNode && binaryNode->blrOp == blr_or) |
| 2240 | { |
| 2241 | InversionCandidateList inversions; |
| 2242 | |
| 2243 | // Make list for index matches |
| 2244 | |
| 2245 | // Copy information from caller |
| 2246 | IndexScratchList indexOrScratches(inputIndexScratches); |
| 2247 | |
| 2248 | // We use a scope variable to see on how |
| 2249 | // deep we are in a nested or conjunction. |
| 2250 | scope++; |
| 2251 | |
| 2252 | auto invCandidate1 = matchOnIndexes(indexOrScratches, binaryNode->arg1, scope); |
| 2253 | |
| 2254 | if (invCandidate1) |
| 2255 | inversions.add(invCandidate1); |
| 2256 | |
| 2257 | auto childBoolNode = nodeAs<BinaryBoolNode>(binaryNode->arg1); |
| 2258 | |
| 2259 | // Get usable inversions based on indexOrScratches and scope |
| 2260 | if (!childBoolNode || childBoolNode->blrOp != blr_or) |
| 2261 | getInversionCandidates(inversions, indexOrScratches, scope); |
| 2262 | |
| 2263 | invCandidate1 = makeInversion(inversions); |
| 2264 | |
| 2265 | // Copy information from caller |
| 2266 | indexOrScratches = inputIndexScratches; |
| 2267 | |
| 2268 | // Clear inversion list |
| 2269 | inversions.clear(); |
| 2270 | |
| 2271 | auto invCandidate2 = matchOnIndexes(indexOrScratches, binaryNode->arg2, scope); |
| 2272 | |
| 2273 | if (invCandidate2) |
| 2274 | inversions.add(invCandidate2); |
| 2275 | |
| 2276 | childBoolNode = nodeAs<BinaryBoolNode>(binaryNode->arg2); |
| 2277 | |
| 2278 | // Make inversion based on indexOrScratches and scope |
| 2279 | if (!childBoolNode || childBoolNode->blrOp != blr_or) |
| 2280 | getInversionCandidates(inversions, indexOrScratches, scope); |
| 2281 | |
| 2282 | invCandidate2 = makeInversion(inversions); |
| 2283 | |
| 2284 | if (invCandidate1 && invCandidate2 && |
| 2285 | (invCandidate1->indexes || invCandidate1->unique) && |
| 2286 | (invCandidate2->indexes || invCandidate2->unique)) |
| 2287 | { |
| 2288 | const auto invCandidate = FB_NEW_POOL(getPool()) InversionCandidate(getPool()); |
| 2289 | invCandidate->inversion = composeInversion(invCandidate1->inversion, |
nothing calls this directly
no test coverage detected