Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
c44ccf28
Commit
c44ccf28
authored
12 years ago
by
Stephen Haberman
Browse files
Options
Downloads
Patches
Plain Diff
Use default parallelism if its set.
parent
44032bc4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/scala/spark/Partitioner.scala
+18
-5
18 additions, 5 deletions
core/src/main/scala/spark/Partitioner.scala
core/src/test/scala/spark/ShuffleSuite.scala
+1
-1
1 addition, 1 deletion
core/src/test/scala/spark/ShuffleSuite.scala
with
19 additions
and
6 deletions
core/src/main/scala/spark/Partitioner.scala
+
18
−
5
View file @
c44ccf28
...
...
@@ -10,12 +10,21 @@ abstract class Partitioner extends Serializable {
}
object
Partitioner
{
private
val
useDefaultParallelism
=
System
.
getProperty
(
"spark.default.parallelism"
)
!=
null
/**
* Choose a partitioner to use for a cogroup-like operation between a number of RDDs. If any of
* the RDDs already has a partitioner, choose that one, otherwise use a default HashPartitioner.
* Choose a partitioner to use for a cogroup-like operation between a number of RDDs.
*
* If any of the RDDs already has a partitioner, choose that one.
*
* The number of partitions will be the same as the number of partitions in the largest upstream
* RDD, as this should be least likely to cause out-of-memory errors.
* Otherwise, we use a default HashPartitioner. For the number of partitions, if
* spark.default.parallelism is set, then we'll use the value from SparkContext
* defaultParallelism, otherwise we'll use the max number of upstream partitions.
*
* Unless spark.default.parallelism is set, He number of partitions will be the
* same as the number of partitions in the largest upstream RDD, as this should
* be least likely to cause out-of-memory errors.
*
* We use two method parameters (rdd, others) to enforce callers passing at least 1 RDD.
*/
...
...
@@ -24,7 +33,11 @@ object Partitioner {
for
(
r
<-
bySize
if
r
.
partitioner
!=
None
)
{
return
r
.
partitioner
.
get
}
return
new
HashPartitioner
(
bySize
.
head
.
partitions
.
size
)
if
(
useDefaultParallelism
)
{
return
new
HashPartitioner
(
rdd
.
context
.
defaultParallelism
)
}
else
{
return
new
HashPartitioner
(
bySize
.
head
.
partitions
.
size
)
}
}
}
...
...
This diff is collapsed.
Click to expand it.
core/src/test/scala/spark/ShuffleSuite.scala
+
1
−
1
View file @
c44ccf28
...
...
@@ -235,7 +235,7 @@ class ShuffleSuite extends FunSuite with ShouldMatchers with LocalSparkContext {
assert
(
rdd
.
values
.
collect
().
toList
===
List
(
"a"
,
"b"
))
}
test
(
"default partitioner uses
split
size"
)
{
test
(
"default partitioner uses
partition
size"
)
{
sc
=
new
SparkContext
(
"local"
,
"test"
)
// specify 2000 partitions
val
a
=
sc
.
makeRDD
(
Array
(
1
,
2
,
3
,
4
),
2000
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment