Actions

As discussed previously, Actions are what makes Spark perform the actual computation from the graph that the framework has been building in the background while you were busy performing transformations on it. While there is a long list of actions offered by Spark, we'll list the most common actions offered by Spark and take you through some of the most common ones:

reduce(func)

takeOrdered(n, [ordering])

collect()

saveAsTextFile(path)

count()

saveAsSequenceFile(path)*

first()

saveAsObjectFile(path) *

take(n)

foreach(func)

takeSample(withReplacement,num, [seed])

Tip

The methods saveAsSequenceFile() and saveAsObjectFil() are only available in Java and Scala.

We have already seen reduce(), collect(), and count() ...

Get Learning Apache Spark 2 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.