Processing Collections using Loops and Map Reduce

As part of this class we have seen

  • Tuple
  • Operations on Map
  • Group by aggregations using loops
  • Group by aggregations using map and groupBy

Get Revenue for Each Order using loops

Get Revenue for Each Order using Map Reduce

Exercise

  • Complete this program to compute revenue for each order
  • Code to get orderItems into collection is available in below gist

  • Now complete this function
def getRevenueForEachOrder(orderItems: List[String]) = {
  orderItems.
    groupBy(k => k.split(",")(1).toInt).
    // Come up with logic to compute the revenue
}