111
Spark Take Function
In Spark, the take function behaves like an array. It receives an integer value (let say, n) as a parameter and returns an array of first n elements of the dataset.
Example of Take function
In this example, we return the first n elements of an existing dataset.
- To open the Spark in Scala mode, follow the below command.
- Create an RDD using the parallelized collection.
- Now, we can read the generated result by using the following command.
- Apply take() function to return an array of elements.
Here, we got the desired output.
Next TopicSpark Word Count Example