Created
October 29, 2015 01:17
-
-
Save prateek/c6f376fb56064f720666 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
// once upon a time, what did I see, but two RDDs | |
val tableA = sc.parallelize(List((1,2), (3,4), (5,6))) | |
val tableB = sc.parallelize(List((1,'A'), (3,'B'), (5,'C'))) | |
// one of them small enough to fit into map | |
val mapTableB = tableB.collectAsMap | |
// which everyone could read | |
val broadcastB = sc.broadcast(mapTableB) | |
// and join for all eternity | |
val mapJoin = tableA.map({case (id, value) => (id, value, broadcastB.value.get(id))}) | |
// q.e.d. | |
mapJoin.collect.map(println) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment