[Learning Apache Spark with Examples] Simple Aggregation

In the last we saw Left Outer join. Let's look at a simple aggregation. Enhancing our Ad example, we would like to see how many Ads from a particular Ad provider did we served. This is a simple scenario of aggregation. We have already seen simple aggregation as part of Word Count example.

The code has minor changes from the join example. Here we make the Ad Provider as key and emit 1 as value, very similar to word count example. To generate the aggregates, we simply call reduceByKey API.