Counts the number of elements within each aggregation. The
transform has three varieties:
Count.globally()counts the number of elements in the entire
PCollection. The result is a collection with a single element.
Count.perKey()counts how many elements are associated with each key. It ignores the values. The resulting collection has one output for every key in the input collection.
Count.perElement()counts how many times each element appears in the input collection. The output collection is a key-value pair, containing each unique element and the number of times it appeared in the original collection.
Example 1: Count.globally
Example 2: Count.perKey
- ApproximateUnique estimates the number of distinct elements or distinct values in key-value pairs
- Sum computes the sum of elements in a collection
Last updated on 2023/10/03
Have you found everything you were looking for?
Was it all useful and clear? Is there anything that you would like to change? Let us know!