use of edu.iu.dsc.tws.tset.sets.batch.ComputeTSet in project beam by apache.
the class BeamBatchWorker method addInputs.
/**
* Adds all the side inputs into the sink test so it is available from the DoFn's.
*/
private void addInputs(BaseTSet sinkTSet, Map<String, CachedTSet> sideInputTSets) {
if (sideInputTSets.isEmpty()) {
return;
}
TBaseGraph graph = sinkTSet.getTBaseGraph();
TBase currNode = null;
Deque<TBase> deque = new ArrayDeque<>();
deque.add(sinkTSet);
while (!deque.isEmpty()) {
currNode = deque.remove();
deque.addAll(graph.getPredecessors(currNode));
if (currNode instanceof ComputeTSet) {
if (((ComputeTSet) currNode).getComputeFunc() instanceof DoFnFunction) {
Set<String> sideInputKeys = ((DoFnFunction) ((ComputeTSet) currNode).getComputeFunc()).getSideInputKeys();
for (String sideInputKey : sideInputKeys) {
if (!sideInputTSets.containsKey(sideInputKey)) {
throw new IllegalStateException("Side input not found for key " + sideInputKey);
}
((ComputeTSet) currNode).addInput(sideInputKey, sideInputTSets.get(sideInputKey));
}
}
}
}
}
Aggregations