Created
September 5, 2019 14:25
-
-
Save dgadiraju/2c0960542f99003980745d4da2909f39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val orderItems = sc.textFile("/public/retail_db/order_items") | |
val orderItemsMap = orderItems. | |
map(oi => (oi.split(",")(1).toInt, oi.split(",")(4).toFloat)) | |
val revenueAndCountPerOrder = orderItemsMap. | |
aggregateByKey((0.0, 0))( | |
(agg, ele) => (agg._1 + ele, agg._2 + 1), | |
(total, inter) => (total._1 + inter._1, total._2 + inter._2) | |
) | |
revenueAndCountPerOrder. | |
take(10). | |
foreach(println) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment