Class Combine.Globally<InputT,OutputT>

java.lang.Object
org.apache.beam.sdk.transforms.PTransform<PCollection<InputT>,PCollection<OutputT>>
org.apache.beam.sdk.transforms.Combine.Globally<InputT,OutputT>
Type Parameters:
InputT - type of input values
OutputT - type of output values
All Implemented Interfaces:
Serializable, HasDisplayData
Enclosing class:
Combine

public static class Combine.Globally<InputT,OutputT> extends PTransform<PCollection<InputT>,PCollection<OutputT>>
Combine.Globally<InputT, OutputT> takes a PCollection<InputT> and returns a PCollection<OutputT> whose elements are the result of combining all the elements in each window of the input PCollection, using a specified CombineFn<InputT, AccumT, OutputT>. It is common for InputT == OutputT, but not required. Common combining functions include sums, mins, maxes, and averages of numbers, conjunctions and disjunctions of booleans, statistical aggregations, etc.

Example of use:


 PCollection<Integer> pc = ...;
 PCollection<Integer> sum = pc.apply(
     Combine.globally(new Sum.SumIntegerFn()));
 

Combining can happen in parallel, with different subsets of the input PCollection being combined separately, and their intermediate results combined further, in an arbitrary tree reduction pattern, until a single result value is produced.

If the input PCollection is windowed into GlobalWindows, a default value in the GlobalWindow will be output if the input PCollection is empty. To use this with inputs with other windowing, either withoutDefaults() or asSingletonView() must be called, as the default value cannot be automatically assigned to any single window.

By default, the Coder of the output PValue<OutputT> is inferred from the concrete type of the CombineFn<InputT, AccumT, OutputT>'s output type OutputT.

See also Combine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)/Combine.PerKey and Combine.groupedValues(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)/Combine.GroupedValues, which are useful for combining values associated with each key in a PCollection of KVs.

See Also: