RDD Operations
RDDs support two types of operations:
Transformations -- create a new RDD from an existing one.
Actions -- return a value to the driver program after running a computation on the RDD.
val rddFromFile = sc.textFile("file:///home/dv6/spark/spark/data/graphx/followers.txt")
val lineLengths = rddFromFile.map(s => s.length)
//if you want to save transformation lineLengths in memory
lineLengths.persist()
//without persist(), lineLengths transformtion will be recompiled
val totalLength = lineLengths.reduce((a, b) => a + b)
Last updated