Search in sources :

Example 1 with TSet

use of edu.iu.dsc.tws.api.tset.sets.TSet in project beam by apache.

the class FlattenTranslatorBatch method translateNode.

@Override
public void translateNode(Flatten.PCollections<T> transform, Twister2BatchTranslationContext context) {
    Collection<PCollection<?>> pcs = context.getInputs().values();
    List<BatchTSetImpl<WindowedValue<T>>> tSets = new ArrayList<>();
    BatchTSetImpl<WindowedValue<T>> unionTSet;
    if (pcs.isEmpty()) {
        final TSetEnvironment tsetEnv = context.getEnvironment();
        unionTSet = ((BatchTSetEnvironment) tsetEnv).createSource(new Twister2EmptySource(), context.getOptions().getParallelism());
    } else {
        for (PValue pc : pcs) {
            BatchTSetImpl<WindowedValue<T>> curr = context.getInputDataSet(pc);
            tSets.add(curr);
        }
        BatchTSetImpl<WindowedValue<T>> first = tSets.remove(0);
        Collection<TSet<WindowedValue<T>>> others = new ArrayList<>();
        others.addAll(tSets);
        if (tSets.size() > 0) {
            unionTSet = first.union(others);
        } else {
            unionTSet = first;
        }
    }
    context.setOutputDataSet(context.getOutput(transform), unionTSet);
}
Also used : Twister2EmptySource(org.apache.beam.runners.twister2.translation.wrappers.Twister2EmptySource) TSetEnvironment(edu.iu.dsc.tws.tset.env.TSetEnvironment) BatchTSetEnvironment(edu.iu.dsc.tws.tset.env.BatchTSetEnvironment) ArrayList(java.util.ArrayList) TSet(edu.iu.dsc.tws.api.tset.sets.TSet) PValue(org.apache.beam.sdk.values.PValue) PCollection(org.apache.beam.sdk.values.PCollection) WindowedValue(org.apache.beam.sdk.util.WindowedValue) BatchTSetImpl(edu.iu.dsc.tws.tset.sets.batch.BatchTSetImpl)

Example 2 with TSet

use of edu.iu.dsc.tws.api.tset.sets.TSet in project beam by apache.

the class BeamBatchWorker method executePipeline.

public void executePipeline(BatchTSetEnvironment env) {
    Map<String, CachedTSet> sideInputTSets = new HashMap<>();
    for (Map.Entry<String, BatchTSet<?>> sides : sideInputDataSets.entrySet()) {
        BatchTSet<?> sideTSet = sides.getValue();
        addInputs((BaseTSet) sideTSet, sideInputTSets);
        CachedTSet tempCache = (CachedTSet) sideTSet.cache();
        sideInputTSets.put(sides.getKey(), tempCache);
    }
    for (TSet leaf : leaves) {
        SinkTSet sinkTSet = (SinkTSet) leaf.direct().sink(new Twister2SinkFunction());
        addInputs(sinkTSet, sideInputTSets);
        eval(env, sinkTSet);
    }
}
Also used : SinkTSet(edu.iu.dsc.tws.tset.sets.batch.SinkTSet) BatchTSet(edu.iu.dsc.tws.api.tset.sets.batch.BatchTSet) CachedTSet(edu.iu.dsc.tws.tset.sets.batch.CachedTSet) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Twister2SinkFunction(org.apache.beam.runners.twister2.translators.functions.Twister2SinkFunction) 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) 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) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

TSet (edu.iu.dsc.tws.api.tset.sets.TSet)2 BatchTSet (edu.iu.dsc.tws.api.tset.sets.batch.BatchTSet)1 BatchTSetEnvironment (edu.iu.dsc.tws.tset.env.BatchTSetEnvironment)1 TSetEnvironment (edu.iu.dsc.tws.tset.env.TSetEnvironment)1 BaseTSet (edu.iu.dsc.tws.tset.sets.BaseTSet)1 BuildableTSet (edu.iu.dsc.tws.tset.sets.BuildableTSet)1 BatchTSetImpl (edu.iu.dsc.tws.tset.sets.batch.BatchTSetImpl)1 CachedTSet (edu.iu.dsc.tws.tset.sets.batch.CachedTSet)1 ComputeTSet (edu.iu.dsc.tws.tset.sets.batch.ComputeTSet)1 SinkTSet (edu.iu.dsc.tws.tset.sets.batch.SinkTSet)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Twister2EmptySource (org.apache.beam.runners.twister2.translation.wrappers.Twister2EmptySource)1 Twister2SinkFunction (org.apache.beam.runners.twister2.translators.functions.Twister2SinkFunction)1 WindowedValue (org.apache.beam.sdk.util.WindowedValue)1 PCollection (org.apache.beam.sdk.values.PCollection)1 PValue (org.apache.beam.sdk.values.PValue)1