use of org.apache.beam.runners.twister2.translation.wrappers.Twister2EmptySource 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);
}
Aggregations