(
source: GraphSource<any>,
input: Iterable<TraversalPath<any, any, any>>,
context?: QueryContext,
)
| 2302 | } |
| 2303 | |
| 2304 | public *traverse( |
| 2305 | source: GraphSource<any>, |
| 2306 | input: Iterable<TraversalPath<any, any, any>>, |
| 2307 | context?: QueryContext, |
| 2308 | ): IterableIterator<TraversalPath<any, any, any>> { |
| 2309 | const { condition, stepLabels } = this.config; |
| 2310 | const indexManager = source.indexManager; |
| 2311 | |
| 2312 | // Convert input to array upfront since we may need to iterate twice |
| 2313 | // (once for index lookup to determine element type, once for filtering) |
| 2314 | const inputArray = Array.from(input); |
| 2315 | |
| 2316 | // Try to use index-based filtering if available |
| 2317 | if (indexManager && inputArray.length > 0) { |
| 2318 | const hints = analyzeCondition(condition); |
| 2319 | if (hints.length > 0) { |
| 2320 | // Try to find a usable index |
| 2321 | const indexResult = this.#tryIndexLookup(source, inputArray, hints, context); |
| 2322 | if (indexResult !== null) { |
| 2323 | yield* indexResult; |
| 2324 | return; |
| 2325 | } |
| 2326 | } |
| 2327 | } |
| 2328 | |
| 2329 | // Fall back to full condition evaluation |
| 2330 | for (const path of inputArray) { |
| 2331 | this.traversed++; |
| 2332 | if (evaluateCondition(path, condition, context)) { |
| 2333 | if (stepLabels !== undefined && stepLabels.length > 0) { |
| 2334 | this.emitted++; |
| 2335 | yield new TraversalPath(path.parent, path.value, stepLabels); |
| 2336 | } else { |
| 2337 | this.emitted++; |
| 2338 | yield path; |
| 2339 | } |
| 2340 | } |
| 2341 | } |
| 2342 | } |
| 2343 | |
| 2344 | /** |
| 2345 | * Try to use an index for filtering. |
nothing calls this directly
no test coverage detected