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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.