Search in sources :

Example 1 with ComputeTSet

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));
                }
            }
        }
    }
}
Also used : DoFnFunction(org.apache.beam.runners.twister2.translators.functions.DoFnFunction) TBaseGraph(edu.iu.dsc.tws.tset.TBaseGraph) TBase(edu.iu.dsc.tws.api.tset.TBase) ArrayDeque(java.util.ArrayDeque) ComputeTSet(edu.iu.dsc.tws.tset.sets.batch.ComputeTSet)

Aggregations

TBase (edu.iu.dsc.tws.api.tset.TBase)1 TBaseGraph (edu.iu.dsc.tws.tset.TBaseGraph)1 ComputeTSet (edu.iu.dsc.tws.tset.sets.batch.ComputeTSet)1 ArrayDeque (java.util.ArrayDeque)1 DoFnFunction (org.apache.beam.runners.twister2.translators.functions.DoFnFunction)1