Search in sources :

Example 1 with TBaseGraph

use of edu.iu.dsc.tws.tset.TBaseGraph 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)

Example 2 with TBaseGraph

use of edu.iu.dsc.tws.tset.TBaseGraph in project beam by apache.

the class BeamBatchWorker method execute.

@Override
public void execute(BatchTSetEnvironment env) {
    Config config = env.getConfig();
    Map<String, String> sideInputIds = (LinkedHashMap<String, String>) config.get(SIDEINPUTS);
    Set<String> leaveIds = (Set<String>) config.get(LEAVES);
    TBaseGraph graph = (TBaseGraph) config.get(GRAPH);
    env.settBaseGraph(graph);
    setupTSets(env, sideInputIds, leaveIds);
    resetEnv(env, graph);
    executePipeline(env);
}
Also used : ComputeTSet(edu.iu.dsc.tws.tset.sets.batch.ComputeTSet) BuildableTSet(edu.iu.dsc.tws.tset.sets.BuildableTSet) CachedTSet(edu.iu.dsc.tws.tset.sets.batch.CachedTSet) SinkTSet(edu.iu.dsc.tws.tset.sets.batch.SinkTSet) Set(java.util.Set) BaseTSet(edu.iu.dsc.tws.tset.sets.BaseTSet) TSet(edu.iu.dsc.tws.api.tset.sets.TSet) BatchTSet(edu.iu.dsc.tws.api.tset.sets.batch.BatchTSet) HashSet(java.util.HashSet) Config(edu.iu.dsc.tws.api.config.Config) TBaseGraph(edu.iu.dsc.tws.tset.TBaseGraph) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

TBaseGraph (edu.iu.dsc.tws.tset.TBaseGraph)2 ComputeTSet (edu.iu.dsc.tws.tset.sets.batch.ComputeTSet)2 Config (edu.iu.dsc.tws.api.config.Config)1 TBase (edu.iu.dsc.tws.api.tset.TBase)1 TSet (edu.iu.dsc.tws.api.tset.sets.TSet)1 BatchTSet (edu.iu.dsc.tws.api.tset.sets.batch.BatchTSet)1 BaseTSet (edu.iu.dsc.tws.tset.sets.BaseTSet)1 BuildableTSet (edu.iu.dsc.tws.tset.sets.BuildableTSet)1 CachedTSet (edu.iu.dsc.tws.tset.sets.batch.CachedTSet)1 SinkTSet (edu.iu.dsc.tws.tset.sets.batch.SinkTSet)1 ArrayDeque (java.util.ArrayDeque)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Set (java.util.Set)1 DoFnFunction (org.apache.beam.runners.twister2.translators.functions.DoFnFunction)1