use of co.cask.cdap.etl.proto.Connection in project cdap by caskdata.
the class Dag method subsetAround.
/**
* Return a subset of this dag starting from the specified stage, without going past any node in the
* child stop nodes and parent stop nodes. If the parent or child stop nodes contain the starting stage, it
* will be ignored.
* This is equivalent to taking the nodes from {@link #accessibleFrom(Set, Set)}, {@link #parentsOf(String, Set)},
* and building a dag from them.
*
* @param stage the stage to start at
* @param childStopNodes set of nodes to stop traversing forwards on
* @param parentStopNodes set of nodes to stop traversing backwards on
* @return a dag created from the stages given and child nodes of those stages and parent nodes of those stages.
*/
public Dag subsetAround(String stage, Set<String> childStopNodes, Set<String> parentStopNodes) {
Set<String> nodes = Sets.union(accessibleFrom(stage, childStopNodes), parentsOf(stage, parentStopNodes));
Set<Connection> connections = new HashSet<>();
for (String node : nodes) {
for (String outputNode : outgoingConnections.get(node)) {
if (nodes.contains(outputNode)) {
connections.add(new Connection(node, outputNode));
}
}
}
return new Dag(connections);
}
Aggregations