From the course: Scala Essential Training for Data Science
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Creating parallel collections - Scala Tutorial
From the course: Scala Essential Training for Data Science
Creating parallel collections
- [Narrator] Let's create some parallel collections. We'll start the scala REPL. Now, there are two ways to create a parallel collection. We can convert a sequential collection into a parallel collection, or we can create a variable or value with a parallel collection type. We'll look at examples of both. So first, let's create a range of a hundred integers, and I'll call that val range, or rng for short, 100, and set that one to 100. Now, I want to create a parallel version, using the par method. I'll do that creating a parallel range 100, which is simply equal to the range we just created, with the par method applied. Notice the type of this object is scala.collection.parallel.immutable.ParRange ParRange is the parallel version of the sequential range object. Let's type the name of the parallel range followed by a period and then hit the tab key. Notice the list of methods includes things like BuilderOps, par, range, iterator, SSCTask, SignallingOps, and TaskOps. These are…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.