Last active
May 23, 2017 08:09
-
-
Save dgadiraju/97306b763b30d1928b4d5e4231b9f555 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 path = "/public/retail_db" or val path = "/Users/itversity/Research/data/retail_db" | |
| val orders = sc.textFile(path + "/orders"). | |
| map(rec => (rec.split(",")(0).toInt, rec)) | |
| val orderItems = sc.textFile(path + "/order_items"). | |
| map(rec => (rec.split(",")(1).toInt, rec)) | |
| val ordersJoin = orders.join(orderItems) | |
| ordersJoin.take(10).foreach(println) | |
| val ordersLeftOuter = orders.leftOuterJoin(orderItems) | |
| ordersLeftOuter.filter(rec => rec._2._2 == None).take(10).foreach(println) | |
| ordersLeftOuter. | |
| filter(rec => rec._2._2 == None). | |
| map(rec => rec._2._1). | |
| take(10). | |
| foreach(println) | |
| val ordersCogroup = orders.cogroup(orderItems) | |
| ordersCogroup.take(10).foreach(println) | |
| val a = sc.parallelize(List(1, 2, 3, 4)) | |
| val b = sc.parallelize(List("Hello", "World")) | |
| a.cartesian(b).foreach(println) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment