VI - type of input valuesVO - type of output valuespublic static class Combine.Globally<VI,VO> extends PTransform<PCollection<VI>,PCollection<VO>>
Combine.Globally<VI, VO> takes a PCollection<VI>
and returns a PCollection<VO> whose single element is the result of
combining all the elements of the input PCollection,
using a specified
CombineFn. It is common
for VI == VO, 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.
By default, the Coder of the output PValue<VO>
is inferred from the concrete type of the
CombineFn<VI, VA, VO>'s output type VO.
See also Combine.perKey(com.google.cloud.dataflow.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)/Combine.PerKey and
Combine.groupedValues(com.google.cloud.dataflow.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.
name| Modifier and Type | Method and Description |
|---|---|
PCollection<VO> |
apply(PCollection<VI> input)
Applies this
PTransform on the given Input, and returns its
Output. |
protected java.lang.String |
getKindString()
Returns a string describing what kind of
PTransform this is. |
finishSpecifying, getCoderRegistry, getDefaultName, getDefaultOutputCoder, getDefaultOutputCoder, getInput, getName, getOutput, getPipeline, setName, setPipeline, toString, withNamepublic PCollection<VO> apply(PCollection<VI> input)
PTransformPTransform on the given Input, and returns its
Output.
Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
The default implementation throws an exception. A derived class must
either implement apply, or else each runner must supply a custom
implementation via
PipelineRunner.apply(com.google.cloud.dataflow.sdk.transforms.PTransform<Input, Output>, Input).
apply in class PTransform<PCollection<VI>,PCollection<VO>>protected java.lang.String getKindString()
PTransformPTransform this is.
By default, returns the base name of this
PTransform's class.
getKindString in class PTransform<PCollection<VI>,PCollection<VO>>