VI - type of input valuesVO - type of output valuespublic static class Combine.GloballyAsSingletonView<VI,VO> extends PTransform<PCollection<VI>,PCollectionView<VO>>
Combine.GloballyAsSingletonView<VI, VO> takes a PCollection<VI>
and returns a PCollectionView<VO> whose elements are the result of
combining all the elements in each window 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.
If a value is requested from the view for a window that is not present
and insertDefault is true, the result of calling the CombineFn
on empty input will returned. If insertDefault is false, an
exception will be thrown instead.
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 |
|---|---|
PCollectionView<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. |
Combine.GloballyAsSingletonView<VI,VO> |
withName(java.lang.String name)
Sets the base name of this
PTransform and returns itself. |
finishSpecifying, getCoderRegistry, getDefaultName, getDefaultOutputCoder, getDefaultOutputCoder, getInput, getName, getOutput, getPipeline, setName, setPipeline, toStringpublic Combine.GloballyAsSingletonView<VI,VO> withName(java.lang.String name)
PTransformPTransform and returns itself.
This is a shortcut for calling PTransform.setName(java.lang.String), which allows method
chaining.
withName in class PTransform<PCollection<VI>,PCollectionView<VO>>public PCollectionView<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>,PCollectionView<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>,PCollectionView<VO>>