T - the type of the elements of the input PCollection, and
the type of the keys of the output PCollectionpublic static class Count.PerElement<T> extends PTransform<PCollection<T>,PCollection<KV<T,java.lang.Long>>>
Count.PerElement<T> takes a PCollection<T> and returns a
PCollection<KV<T, Long>> representing a map from each
distinct element of the input PCollection to the number of times
that element occurs in the input. Each of the keys in the output
PCollection is unique.
This transform compares two values of type T by first
encoding each element using the input PCollection's
Coder, then comparing the encoded bytes. Because of this,
the input coder must be deterministic. (See
Coder.verifyDeterministic() for more detail).
Performing the comparison in this manner admits efficient parallel evaluation.
By default, the Coder of the keys of the output
PCollection is the same as the Coder of the
elements of the input PCollection.
Example of use:
PCollection<String> words = ...;
PCollection<KV<String, Long>> wordCounts =
words.apply(Count.<String>perElement());
name| Constructor and Description |
|---|
Count.PerElement() |
| Modifier and Type | Method and Description |
|---|---|
PCollection<KV<T,java.lang.Long>> |
apply(PCollection<T> input)
Applies this
PTransform on the given Input, and returns its
Output. |
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<KV<T,java.lang.Long>> apply(PCollection<T> 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<T>,PCollection<KV<T,java.lang.Long>>>public java.lang.String getKindString()
PTransformPTransform this is.
By default, returns the base name of this
PTransform's class.
getKindString in class PTransform<PCollection<T>,PCollection<KV<T,java.lang.Long>>>