/** * Replace shareable nodes in a graph. * * @param replace A replacement function. For each shareable node, this function will * be called; if it returns a node different from its input node, the * new node will be used as a replacement for the old. */ private DAGNode<Component,Dependency> replaceShareableNodes(NodeProcessor replace) throws InjectionException { logger.debug("replacing nodes in graph with {} nodes", graph.getReachableNodes().size()); Set<DAGNode<Component,Dependency>> toReplace = GraphtUtils.getShareableNodes(graph); logger.debug("found {} shared nodes", toReplace.size()); DAGNode<Component, Dependency> result = NodeProcessors.processNodes(graph, toReplace, replace); logger.debug("final graph has {} nodes", result.getReachableNodes().size()); return result; } }
@Override protected DAGNode<Component, Dependency> instantiateGraph(DAGNode<Component, Dependency> graph) { if (cache == null) { logger.debug("Building directly without a cache"); return super.instantiateGraph(graph); } else { logger.debug("Instantiating graph with a cache"); try { Set<DAGNode<Component, Dependency>> nodes = GraphtUtils.getShareableNodes(graph); logger.debug("resolving {} nodes", nodes.size()); DAGNode<Component, Dependency> newGraph = NodeProcessors.processNodes(graph, nodes, cache); logger.debug("newGraph went from {} to {} nodes", newGraph.getReachableNodes().size(), newGraph.getReachableNodes().size()); return newGraph; } catch (InjectionException e) { logger.error("Error instantiating recommender nodes with cache", e); throw new RecommenderBuildException("Cached instantiation failed", e); } } } }
/** * Replace shareable nodes in a graph. * * @param replace A replacement function. For each shareable node, this function will * be called; if it returns a node different from its input node, the * new node will be used as a replacement for the old. */ private DAGNode<Component,Dependency> replaceShareableNodes(NodeProcessor replace) throws InjectionException { logger.debug("replacing nodes in graph with {} nodes", graph.getReachableNodes().size()); Set<DAGNode<Component,Dependency>> toReplace = GraphtUtils.getShareableNodes(graph); logger.debug("found {} shared nodes", toReplace.size()); DAGNode<Component, Dependency> result = NodeProcessors.processNodes(graph, toReplace, replace); logger.debug("final graph has {} nodes", result.getReachableNodes().size()); return result; } }
Set<DAGNode<Component, Dependency>> nodes = GraphtUtils.getShareableNodes(cfgGraph); logger.debug("resolving {} nodes", nodes.size()); graph = NodeProcessors.processNodes(cfgGraph, nodes, cache); logger.debug("graph went from {} to {} nodes", cfgGraph.getReachableNodes().size(),