for (DAGEdge<Component,Dependency> edge: node.getOutgoingEdges()) { if (!edgeIsTransient(edge)) { boolean es = shared.contains(edge.getTail());
@Override public void describe(DAGNode<Component, Dependency> node, DescriptionWriter description) { node.getLabel().getSatisfaction().visit(new LabelDescriptionVisitor(description)); description.putField("cachePolicy", node.getLabel().getCachePolicy().name()); List<DAGNode<Component, Dependency>> edges = node.getOutgoingEdges() .stream() .sorted(GraphtUtils.DEP_EDGE_ORDER) .map(DAGEdge::getTail) .collect(Collectors.toList()); description.putList("dependencies", edges, INSTANCE); } }
String rid = dumper.setRoot(graph); for (DAGEdge<Component, Dependency> e: graph.getOutgoingEdges()) { DAGNode<Component, Dependency> target = e.getTail(); Component csat = target.getLabel();
for (DAGEdge<Component, Dependency> edge: node.getOutgoingEdges()) { if (!GraphtUtils.edgeIsTransient(edge)) { bld.addEdge(edge.getTail(), edge.getLabel());
.setShared(!unsharedNodes.contains(currentNode)) .setIsProvider(pid != null); List<DAGEdge<Component, Dependency>> edges = Lists.newArrayList(currentNode.getOutgoingEdges()); Collections.sort(edges, GraphtUtils.DEP_EDGE_ORDER); for (DAGEdge<Component, Dependency> e: edges) {
public DAGNode<Component, Dependency> processNode(@Nonnull DAGNode<Component, Dependency> node, @Nonnull DAGNode<Component, Dependency> original) { Component label = node.getLabel(); if (!label.getSatisfaction().hasInstance()) { Satisfaction instanceSat = Satisfactions.nullOfType(label.getSatisfaction().getErasedType()); Component newLbl = Component.create(instanceSat, label.getCachePolicy()); // build new node with replacement label DAGNodeBuilder<Component,Dependency> bld = DAGNode.newBuilder(newLbl); // retain all non-transient edges for (DAGEdge<Component,Dependency> edge: node.getOutgoingEdges()) { if (!GraphtUtils.edgeIsTransient(edge)) { bld.addEdge(edge.getTail(), edge.getLabel()); } } DAGNode<Component,Dependency> repl = bld.build(); logger.debug("simulating instantiation of {}", node); return repl; } else { return node; } } }
public DAGNode<Component, Dependency> processNode(@Nonnull DAGNode<Component, Dependency> node, @Nonnull DAGNode<Component, Dependency> original) { Component label = node.getLabel(); Satisfaction satisfaction = label.getSatisfaction(); if (satisfaction.hasInstance()) { return node; } Object obj = instantiator.apply(node); Satisfaction instanceSat; if (obj == null) { instanceSat = Satisfactions.nullOfType(satisfaction.getErasedType()); } else { instanceSat = Satisfactions.instance(obj); } Component newLabel = Component.create(instanceSat, label.getCachePolicy()); // build new node with replacement label DAGNodeBuilder<Component,Dependency> bld = DAGNode.newBuilder(newLabel); // retain all non-transient edges for (DAGEdge<Component, Dependency> edge: node.getOutgoingEdges()) { if (!GraphtUtils.edgeIsTransient(edge)) { bld.addEdge(edge.getTail(), edge.getLabel()); } } return bld.build(); } }
while (!work.isEmpty()) { DAGNode<V, E> node = work.remove(); for (DAGEdge<V, E> e : node.getOutgoingEdges()) {
private Map<Desire, Instantiator> makeDependencyMap(DAGNode<Component, Dependency> node, SetMultimap<DAGNode<Component, Dependency>, DAGEdge<Component, Dependency>> backEdges) { Set<DAGEdge<Component,Dependency>> edges = node.getOutgoingEdges(); if (backEdges.containsKey(node)) { ImmutableSet.Builder<DAGEdge<Component,Dependency>> bld = ImmutableSet.builder(); edges = bld.addAll(edges) .addAll(backEdges.get(node)) .build(); } ImmutableSet.Builder<Desire> desires = ImmutableSet.builder(); for (DAGEdge<Component,Dependency> edge: edges) { desires.add(edge.getLabel().getInitialDesire()); } return Maps.asMap(desires.build(), new DepLookup(edges, backEdges)); }
/** * Do a breadth-first search for an edge. * * @param pred The predicate for matching nodes. * @return The first node matching {@code pred} in a breadth-first search, or {@code null} if no * such node is found. */ public DAGEdge<V, E> findEdgeBFS(@Nonnull Predicate<? super DAGEdge<V, E>> pred) { Queue<DAGNode<V, E>> work = Lists.newLinkedList(); Set<DAGNode<V, E>> seen = Sets.newHashSet(); work.add(this); seen.add(this); while (!work.isEmpty()) { DAGNode<V, E> node = work.remove(); for (DAGEdge<V, E> e : node.getOutgoingEdges()) { // is this the edge we are looking for? if (pred.apply(e)) { return e; } else if (!seen.contains(e.getTail())) { seen.add(e.getTail()); work.add(e.getTail()); } } } // no node found return null; }
for (DAGEdge<Component,Dependency> edge: node.getOutgoingEdges()) { if (!edgeIsTransient(edge)) { boolean es = shared.contains(edge.getTail());
/** * Create a new builder initialized to build a copy of the specified node. * @param node The node to copy. * @param <V> The type of node labels. * @param <E> The type of edge labels. * @return A new builder initialized with the labels and edges of {@code node}. */ public static <V,E> DAGNodeBuilder<V,E> copyBuilder(DAGNode<V,E> node) { DAGNodeBuilder<V,E> bld = newBuilder(node.getLabel()); for (DAGEdge<V,E> edge: node.getOutgoingEdges()) { bld.addEdge(edge.getTail(), edge.getLabel()); } return bld; }
@Override public void describe(DAGNode<Component, Dependency> node, DescriptionWriter description) { node.getLabel().getSatisfaction().visit(new LabelDescriptionVisitor(description)); description.putField("cachePolicy", node.getLabel().getCachePolicy().name()); List<DAGNode<Component, Dependency>> edges = Lists.transform(GraphtUtils.DEP_EDGE_ORDER.sortedCopy(node.getOutgoingEdges()), DAGEdge.<Component,Dependency>extractTail()); description.putList("dependencies", edges, INSTANCE); } }
DAGNode<Component, Dependency> parent = current.node; assert parent.getOutgoingEdges().isEmpty();
String rid = dumper.setRoot(graph); for (DAGEdge<Component, Dependency> e: graph.getOutgoingEdges()) { DAGNode<Component, Dependency> target = e.getTail(); Component csat = target.getLabel();
public DAGNode<Component, Dependency> processNode(@Nonnull DAGNode<Component, Dependency> node, @Nonnull DAGNode<Component, Dependency> original) { Component label = node.getLabel(); if (!label.getSatisfaction().hasInstance()) { Satisfaction instanceSat = Satisfactions.nullOfType(label.getSatisfaction().getErasedType()); Component newLbl = Component.create(instanceSat, label.getCachePolicy()); // build new node with replacement label DAGNodeBuilder<Component,Dependency> bld = DAGNode.newBuilder(newLbl); // retain all non-transient edges for (DAGEdge<Component,Dependency> edge: node.getOutgoingEdges()) { if (!GraphtUtils.edgeIsTransient(edge)) { bld.addEdge(edge.getTail(), edge.getLabel()); } } DAGNode<Component,Dependency> repl = bld.build(); logger.debug("simulating instantiation of {}", node); return repl; } else { return node; } } }
.setShared(!unsharedNodes.contains(currentNode)) .setIsProvider(pid != null); List<DAGEdge<Component, Dependency>> edges = Lists.newArrayList(currentNode.getOutgoingEdges()); Collections.sort(edges, GraphtUtils.DEP_EDGE_ORDER); for (DAGEdge<Component, Dependency> e: edges) {
public DAGNode<Component, Dependency> processNode(@Nonnull DAGNode<Component, Dependency> node, @Nonnull DAGNode<Component, Dependency> original) { Component label = node.getLabel(); Satisfaction satisfaction = label.getSatisfaction(); if (satisfaction.hasInstance()) { return node; } Object obj = instantiator.apply(node); Satisfaction instanceSat; if (obj == null) { instanceSat = Satisfactions.nullOfType(satisfaction.getErasedType()); } else { instanceSat = Satisfactions.instance(obj); } Component newLabel = Component.create(instanceSat, label.getCachePolicy()); // build new node with replacement label DAGNodeBuilder<Component,Dependency> bld = DAGNode.newBuilder(newLabel); // retain all non-transient edges for (DAGEdge<Component, Dependency> edge: node.getOutgoingEdges()) { if (!GraphtUtils.edgeIsTransient(edge)) { bld.addEdge(edge.getTail(), edge.getLabel()); } } return bld.build(); } }
Map<DAGEdge<Component, Dependency>, DAGEdge<Component, Dependency>> replacements) throws ResolutionException { assert context.getTailValue().getLeft().equals(root.getLabel().getSatisfaction()); for (DAGEdge<Component, Dependency> edge: root.getOutgoingEdges()) { logger.debug("considering {} for replacement", edge.getTail().getLabel()); Desire desire = edge.getLabel().getDesireChain().getInitialDesire();
for (DAGEdge<Component, Dependency> edge: node.getOutgoingEdges()) { if (!GraphtUtils.edgeIsTransient(edge)) { bld.addEdge(edge.getTail(), edge.getLabel());