Skip to content

Instantly share code, notes, and snippets.

@dgadiraju
Last active March 4, 2018 16:29
Show Gist options
  • Save dgadiraju/7da6b7c3c04358007c4fae0951f14864 to your computer and use it in GitHub Desktop.
Save dgadiraju/7da6b7c3c04358007c4fae0951f14864 to your computer and use it in GitHub Desktop.
val path = "/public/retail_db" or val path = "/Users/itversity/Research/data/retail_db"
val rdd = sc.textFile(path + "/orders")
rdd.reduce((agg, ele) => {
if(agg.split(",")(2).toInt < ele.split(",")(2).toInt) agg else ele
})
rdd.top(2)
rdd.takeOrdered(5)(Ordering[Int].reverse.on(x => x.split(",")(2).toInt)).foreach(println)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment