51. [Activity] Superhero Degrees of Seperation using GraphX
GraphX in Action
Activity
Looking At The Code
import org.apache.spark.graphx._ // Function to extract hero ID -> hero name tuples (or None in case of failure)
def parseNames(line: String) : Option[(VertexId, String)] = {
var fields = line.split('\"')
if (fields.length > 1) {
val heroID:Long = fields(0).trim().toLong
if (heroID < 6487) { // ID's above 6486 aren't real characters
return Some( fields(0).trim().toLong, fields(1))
}
}
}Previous50. GraphX, Pregel, and Breadth-First-Search with Pregel.Next52. Learning More, and Career Tips
Last updated