Package org.apache.beam.sdk.transforms
Class CombineFns
- java.lang.Object
-
- org.apache.beam.sdk.transforms.CombineFns
-
public class CombineFns extends java.lang.Object
Static utility methods that create combine function instances.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CombineFns.CoCombineResult
A tuple of outputs produced by a composed combine functions.static class
CombineFns.ComposeCombineFnBuilder
A builder class to construct a composedCombineFnBase.GlobalCombineFn
.static class
CombineFns.ComposedCombineFn<DataT>
A composedCombine.CombineFn
that applies multipleCombineFns
.static class
CombineFns.ComposedCombineFnWithContext<DataT>
A composedCombineWithContext.CombineFnWithContext
that applies multipleCombineFnWithContexts
.
-
Constructor Summary
Constructors Constructor Description CombineFns()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CombineFns.ComposeCombineFnBuilder
compose()
Returns aCombineFns.ComposeCombineFnBuilder
to construct a composedCombineFnBase.GlobalCombineFn
.
-
-
-
Method Detail
-
compose
public static CombineFns.ComposeCombineFnBuilder compose()
Returns aCombineFns.ComposeCombineFnBuilder
to construct a composedCombineFnBase.GlobalCombineFn
.The same
TupleTag
cannot be used in a composition multiple times.Example:
PCollection<Integer> globalLatencies = ...; TupleTag<Integer> maxLatencyTag = new TupleTag<Integer>(); TupleTag<Double> meanLatencyTag = new TupleTag<Double>();
SimpleFunction<Integer, Integer> identityFn = new SimpleFunction<Integer, Integer>()
{@Override public Integer apply(Integer input) { return input; }
};PCollection<CoCombineResult> maxAndMean = globalLatencies.apply( Combine.globally( CombineFns.compose() .with(identityFn, new MaxIntegerFn(), maxLatencyTag) .with(identityFn, new MeanFn<Integer>(), meanLatencyTag)))
;PCollection<T> finalResultCollection = maxAndMean .apply(ParDo.of( new DoFn<CoCombineResult, T>()
{@ProcessElement public void processElement(
@Element CoCombineResult e, OutputReceiver<T> r) throws Exception { Integer maxLatency = e.get(maxLatencyTag); Double meanLatency = e.get(meanLatencyTag); .... Do Something .... r.output(...some T...); }
}));
-
-