com.google.cloud.dataflow.sdk.transforms

## 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 input `PCollection`, and the type of the keys of the output `PCollection`

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 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 key 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());

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
`PCollection<KV<T,Long>>` `apply(PCollection<T> input)` Applies this `PTransform` on the given `InputT`, and returns its `Output`.

### Methods inherited from class com.google.cloud.dataflow.sdk.transforms.PTransform

`getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, populateDisplayData, toString, validate`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### PerElement

    public PerElement()

### Method Detail

#### apply

    public PCollection<KV<T,Long>> apply(PCollection<T> input)

Description copied from class: `PTransform`
Applies this `PTransform` on the given `InputT`, 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<InputT, OutputT>, InputT)`.

Overrides:
  `apply` in class `PTransform<PCollection<T>,PCollection<KV<T,Long>>>`