Google Cloud Dataflow SDK for Java, version 1.9.1
Class Count.PerElement<T>
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.transforms.PTransform<PCollection<T>,PCollection<KV<T,Long>>>
-
- com.google.cloud.dataflow.sdk.transforms.Count.PerElement<T>
-
- Type Parameters:
T
- the type of the elements of the inputPCollection
, and the type of the keys of the outputPCollection
- All Implemented Interfaces:
- HasDisplayData, Serializable
- Enclosing class:
- Count
public static class Count.PerElement<T> extends PTransform<PCollection<T>,PCollection<KV<T,Long>>>
Count.PerElement<T>
takes aPCollection<T>
and returns aPCollection<KV<T, Long>>
representing a map from each distinct element of the inputPCollection
to the number of times that element occurs in the input. Each key in the outputPCollection
is unique.This transform compares two values of type
T
by first encoding each element using the inputPCollection
'sCoder
, then comparing the encoded bytes. Because of this, the input coder must be deterministic. (SeeCoder.verifyDeterministic()
for more detail). Performing the comparison in this manner admits efficient parallel evaluation.By default, the
Coder
of the keys of the outputPCollection
is the same as theCoder
of the elements of the inputPCollection
.Example of use:
PCollection<String> words = ...; PCollection<KV<String, Long>> wordCounts = words.apply(Count.<String>perElement());
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.google.cloud.dataflow.sdk.transforms.PTransform
name
-
-
Constructor Summary
Constructors Constructor and Description PerElement()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description PCollection<KV<T,Long>>
apply(PCollection<T> input)
Applies thisPTransform
on the givenInputT
, and returns itsOutput
.-
Methods inherited from class com.google.cloud.dataflow.sdk.transforms.PTransform
getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, populateDisplayData, toString, validate
-
-
-
-
Method Detail
-
apply
public PCollection<KV<T,Long>> apply(PCollection<T> input)
Description copied from class:PTransform
Applies thisPTransform
on the givenInputT
, and returns itsOutput
.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<InputT, OutputT>, InputT)
.- Overrides:
apply
in classPTransform<PCollection<T>,PCollection<KV<T,Long>>>
-
-