8000 Added a few documents to the parallel collections overview, along wit… · soc-mirror/scala.github.com@3890412 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3890412

Browse files
committed
Added a few documents to the parallel collections overview, along with some corrections and refactoring to existing documents in the overview.
1 parent 8f2bb75 commit 3890412

File tree

9 files changed

+293
-246
lines changed

9 files changed

+293
-246
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
layout: overview-large
3+
title: Architecture of the Parallel Collections Library
4+
5+
disqus: true
6+
7+
partof: parallel-collections
8+
num: 5
9+
---
10+
11+
Like the normal, sequential collections library, Scala's parallel collections
12+
library contains a large number of collection operations which exist uniformly
13+
on many different parallel collection implementations. And like the normal,
14+
sequential collections library, Scala's parallel collections library seeks to
15+
prevent code duplication by likewise implementing most operations in terms of
16+
parallel collection "templates" which need only be defined once and can be
17+
flexibly inherited by many different parallel collection implementations.
18+
19+
The benefits of this approach are greatly eased **maintenance** and
20+
**extensibility**. In the case of maintenance-- by having a single
21+
implementation of a parallel collections operation inherited by all parallel
22+
collections, maintenance becomes easier and more robust; bug fixes propagate
23+
down the class hierarchy, rather than needing implementations to be
24+
duplicated. For the same reasons, the entire library becomes easier to
25+
extend-- new collection classes can simply inherit most of their operations.
26+
27+
## Core Abstractions
28+
29+
The aforementioned "template" traits implement most parallel operations in
30+
terms of two core abstractions-- `Splitter`s and `Combiner`s.
31+
32+
### Splitters
33+
34+
The job of a `Splitter`, as its name suggests, is to split a parallel
35+
collection into a non-trival partition of its elements. The basic idea is to
36+
split the collection into smaller parts until they are small enough to be
37+
operated on sequentially.
38+
39+
Interestingly, `Splitter`s are implemented as `Iterator`s, meaning that apart
40+
from splitting, they are also used by the framework to traverse a given
41+
parallel collection. What's more, as a type of `Iterator`, a `Splitter` can be
42+
`split` further into additional `Splitter`s which each traverse over disjoint
43+
subsets of elements of the whole parallel collection. Typically, this `split`
44+
operation is repeated recursively until the size of the split partitions is
45+
sufficiently small.
46+
47+
### Combiners
48+
49+
50+
51+
## Hierarchy
52+

overviews/parallel-collections/concrete-parallel-collections.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ partof: parallel-collections
88
num: 2
99
---
1010

11-
**Aleksandar Prokopec**
12-
1311
## Parallel Array
1412

1513
A [ParArray](http://www.scala-lang.org/api/{{ site.scala-version }}/scala/collection/parallel/mutable/ParArray.html) sequence holds an linear, contiguous array of elements. This means that the elements can be accessed and updated efficiently through modifying the underlying array. Traversing the elements is also very efficient for this reason. Parallel arrays are like arrays in the sense that their size is constant.

overviews/parallel-collections/configuration.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,9 @@ title: Configuring Parallel Collections
55
disqus: true
66

77
partof: parallel-collections
8-
num: 2
8+
num: 7
99
---
1010

11-
**Aleksandar Prokopec**
12-
13-
14-
15-
1611
## Task support
1712

1813
Parallel collections are modular in the way operations are scheduled. Each parallel

overviews/parallel-collections/conversions.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ title: Parallel Collection Conversions
55
disqus: true
66

77
partof: parallel-collections
8-
num: 2
8+
num: 3
99
---
1010

11-
**Aleksandar Prokopec**
12-
13-
1411
## Converting between sequential and parallel collections
1512

1613
Every sequential collection can be converted to its parallel variant
17-
using the `par` method. Certain sequential collection have their
14+
using the `par` method. Certain sequential collections have their
1815
direct parallel counterparts. For these collections the conversion is
1916
efficient - it occurs in constant time, since both the sequential and
2017
the parallel collection have the same data-structural representation
@@ -37,12 +34,12 @@ visible in its parallel counterpart if they share the underlying data-structure.
3734
| `HashMap` | `ParHashMap` |
3835
| `HashSet` | `ParHashSet` |
3936

40-
Other collections, such as lists, queues or streams, are inherently
41-
sequential in the sense that the elements must be accessed in
42-
one after the other. These collections are converted to their parallel
43-
variants by copying the elements into a similar parallel collection.
44-
For example, a functional list is converted into a standard immutable
45-
parallel sequence, which is a parallel vector.
37+
Other collections, such as lists, queues or streams, are inherently sequential
38+
in the sense that the elements must be accessed one after the other. These
39+
collections are converted to their parallel variants by copying the elements
40+
into a similar parallel collection. For example, a functional list is
41+
converted into a standard immutable parallel sequence, which is a parallel
42+
vector.
4643

4744
Every parallel collection can be converted to its sequential variant
4845
using the `seq` method. Converting a parallel collection to a

overviews/parallel-collections/ctries.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ title: Concurrent Tries
55
disqus: true
66

77
partof: parallel-collections
8-
num: 2
8+
num: 4
99
---
1010

11-
**Aleksandar Prokopec**
12-
13-
1411
Most concurrent data structures do not guarantee consistent
1512
traversal if the the data structure is modified during traversal.
1613
This is, in fact, the case with most mutable collections, too.

overviews/parallel-collections/custom-parallel-collections.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ title: Creating Custom Parallel Collections
55
disqus: true
66

77
partof: parallel-collections
8-
num: 2
8+
num: 6
99
---
1010

11-
**Aleksandar Prokopec**
12-
13-
1411
## Parallel collections without combiners
1512

1613
Just as it is possible to define custom sequential collections without defining their builders,

overviews/parallel-collections/introduction.md

Lines changed: 0 additions & 213 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0