boolean fixedPoint; do { Iterator<HepRelVertex> iter = getGraphIterator(programState, requireNonNull(root, "root")); fixedPoint = true; while (iter.hasNext()) { HepRelVertexvertex= iter.next(); for (RelOptRule rule : rules) { HepRelVertexnewVertex= applyRule(rule, vertex, forceConversions); if (newVertex == null || newVertex == vertex) { continue; } ++nMatches; if (nMatches >= programState.matchLimit) { return; } if (fullRestartAfterTransformation) { iter = getGraphIterator(programState, requireNonNull(root, "root")); } else { // To the extent possible, pick up where we left // off; have to create a new iterator because old // one was invalidated by transformation. iter = getGraphIterator(programState, newVertex); if (programState.matchOrder == HepMatchOrder.DEPTH_FIRST) { nMatches = depthFirstApply(programState, iter, rules, forceConversions, nMatches); if (nMatches >= programState.matchLimit) { return; } } // Remember to go around again since we're // skipping some stuff. fixedPoint = false; } break; } } } while (!fixedPoint); }
for (HepInstruction instruction : currentProgram.instructions) { instruction.execute(this); intdelta= nTransformations - nTransformationsLastGC; if (delta > graphSizeLastGC) { // The number of transformations performed since the last // garbage collection is greater than the number of vertices in // the graph at that time. That means there should be a // reasonable amount of garbage to collect now. We do it this // way to amortize garbage collection cost over multiple // instructions, while keeping the highwater memory usage // proportional to the graph size. collectGarbage(); } }
boolean fixedPoint; do { Iterator<HepRelVertex> iter = getGraphIterator(requireNonNull(root, "root")); fixedPoint = true; while (iter.hasNext()) { HepRelVertexvertex= iter.next(); for (RelOptRule rule : rules) { HepRelVertexnewVertex= applyRule(rule, vertex, forceConversions); if (newVertex == null || newVertex == vertex) { continue; } ++nMatches; if (nMatches >= requireNonNull(currentProgram, "currentProgram").matchLimit) { return; } if (fullRestartAfterTransformation) { iter = getGraphIterator(requireNonNull(root, "root")); } else { // To the extent possible, pick up where we left // off; have to create a new iterator because old // one was invalidated by transformation. iter = getGraphIterator(newVertex); if (requireNonNull(currentProgram, "currentProgram").matchOrder == HepMatchOrder.DEPTH_FIRST) { nMatches = depthFirstApply(iter, rules, forceConversions, nMatches); if (nMatches >= requireNonNull(currentProgram, "currentProgram").matchLimit) { return; } } // Remember to go around again since we're // skipping some stuff. fixedPoint = false; } break; } } } while (!fixedPoint);