Combine.GloballyAsSingletonView takes a
PCollectionand returns a
PCollectionView 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
InputT ==, 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 pc = ...;
Combining can happen in parallel, with different subsets of the input
PCollectionbeing 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 is inferred from the
concrete type of the
CombineFn's output type
OutputT.
See also
#perKey/
PerKey and
#groupedValues/
GroupedValues, which are useful for combining values associated with
each key in a
PCollection of
KVs.