33
33
import java .util .Collections ;
34
34
import java .util .Iterator ;
35
35
import java .util .LinkedHashSet ;
36
- import java .util .LinkedList ;
37
36
import java .util .List ;
38
37
import java .util .Queue ;
39
38
import java .util .Set ;
@@ -182,11 +181,7 @@ public Output<?> output(String output) {
182
181
}
183
182
return new Output (operation , index );
184
183
} catch (NumberFormatException e ) {
185
- GraphOperation op = operation (output );
186
- if (op == null ) {
187
- return null ;
188
- }
189
- return new Output (op , 0 );
184
+ throw new IllegalArgumentException ("Could not get output for badly formatted output name: \" " + output + "\" " , e );
190
185
}
191
186
}
192
187
@@ -343,7 +338,7 @@ public synchronized Set<GraphOperation> completeSubgraph(Set<Operand<?>> inputs,
343
338
* @param outputs the starting points of the traversal.
344
339
* @return the ops needed to calculate {@code outputs}, not including {@code outputs}
345
340
*/
346
- public Set <GraphOperation > upstreamOps (Set <GraphOperation > outputs ) {
341
+ public Set <GraphOperation > subgraphToOps (Set <GraphOperation > outputs ) {
347
342
Set <GraphOperation > seen = new LinkedHashSet <>(outputs .size ());
348
343
Queue <GraphOperation > todo = new ArrayDeque <>(outputs );
349
344
while (!todo .isEmpty ()) {
@@ -365,7 +360,7 @@ public Set<GraphOperation> upstreamOps(Set<GraphOperation> outputs) {
365
360
* @param inputs the starting points of the traversal.
366
361
* @return the ops that depend on {@code inputs}, not including {@code inputs}
367
362
*/
368
- public synchronized Set <GraphOperation > downstreamOps (Set <GraphOperation > inputs ) {
363
+ public synchronized Set <GraphOperation > subgraphFromOps (Set <GraphOperation > inputs ) {
369
364
Set <GraphOperation > seen = new LinkedHashSet <>(inputs .size ());
370
365
Queue <GraphOperation > todo = new ArrayDeque <>(inputs );
371
366
while (!todo .isEmpty ()) {
@@ -387,8 +382,8 @@ public synchronized Set<GraphOperation> downstreamOps(Set<GraphOperation> inputs
387
382
* @param outputs the starting points of the traversal.
388
383
* @return the ops needed to calculate {@code outputs}, not including {@code outputs}
389
384
*/
390
- public Set <GraphOperation > upstream (Set <Operand <?>> outputs ) {
391
- return upstreamOps (outputs .stream ().map (this ::graphOp ).collect (Collectors .toSet ()));
385
+ public Set <GraphOperation > subgraphTo (Set <Operand <?>> outputs ) {
386
+ return subgraphToOps (outputs .stream ().map (this ::graphOp ).collect (Collectors .toSet ()));
392
387
}
393
388
394
389
/**
@@ -398,14 +393,14 @@ public Set<GraphOperation> upstream(Set<Operand<?>> outputs) {
398
393
* @param inputs the starting points of the traversal.
399
394
* @return the ops that depend on {@code inputs}, not including {@code inputs}
400
395
*/
401
- public synchronized Set <GraphOperation > downstream (Set <Operand <?>> inputs ) {
396
+ public synchronized Set <GraphOperation > subgraphFrom (Set <Operand <?>> inputs ) {
402
397
Set <GraphOperation > ops = new LinkedHashSet <>();
403
398
for (Operand <?> input : inputs ) {
404
399
GraphOperation op = graphOp (input );
405
400
ops .addAll (op .consumers (input .asOutput ().index ()));
406
401
ops .addAll (op .controlConsumers ());
407
402
}
408
- Set <GraphOperation > downstream = downstreamOps (ops );
403
+ Set <GraphOperation > downstream = subgraphFromOps (ops );
409
404
downstream .addAll (ops );
410
405
return downstream ;
411
406
}
0 commit comments