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
a8a2a08a
Commit
a8a2a08a
authored
12 years ago
by
Reynold Xin
Browse files
Options
Downloads
Patches
Plain Diff
Added a test for testing map-side combine on/off switch.
parent
5945bcdc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/src/test/scala/spark/ShuffleSuite.scala
+44
-1
44 additions, 1 deletion
core/src/test/scala/spark/ShuffleSuite.scala
with
44 additions
and
1 deletion
core/src/test/scala/spark/ShuffleSuite.scala
+
44
−
1
View file @
a8a2a08a
...
...
@@ -2,6 +2,7 @@ package spark
import
org.scalatest.FunSuite
import
org.scalatest.BeforeAndAfter
import
org.scalatest.matchers.ShouldMatchers
import
org.scalatest.prop.Checkers
import
org.scalacheck.Arbitrary._
import
org.scalacheck.Gen
...
...
@@ -13,7 +14,7 @@ import scala.collection.mutable.ArrayBuffer
import
SparkContext._
class
ShuffleSuite
extends
FunSuite
with
BeforeAndAfter
{
class
ShuffleSuite
extends
FunSuite
with
ShouldMatchers
with
BeforeAndAfter
{
var
sc
:
SparkContext
=
_
...
...
@@ -196,4 +197,46 @@ class ShuffleSuite extends FunSuite with BeforeAndAfter {
// Test that a shuffle on the file works, because this used to be a bug
assert
(
file
.
map
(
line
=>
(
line
,
1
)).
reduceByKey
(
_
+
_
).
collect
().
toList
===
Nil
)
}
test
(
"map-side combine"
)
{
sc
=
new
SparkContext
(
"local"
,
"test"
)
val
pairs
=
sc
.
parallelize
(
Array
((
1
,
1
),
(
1
,
2
),
(
1
,
3
),
(
1
,
1
),
(
2
,
1
),
(
1
,
1
)),
2
)
// Test with map-side combine on.
val
sums
=
pairs
.
reduceByKey
(
_
+
_
).
collect
()
assert
(
sums
.
toSet
===
Set
((
1
,
8
),
(
2
,
1
)))
// Turn off map-side combine and test the results.
val
aggregator
=
new
Aggregator
[
Int
,
Int
,
Int
](
(
v
:
Int
)
=>
v
,
_
+
_
,
_
+
_
,
false
)
val
shuffledRdd
=
new
ShuffledRDD
(
pairs
,
aggregator
,
new
HashPartitioner
(
2
))
assert
(
shuffledRdd
.
collect
().
toSet
===
Set
((
1
,
8
),
(
2
,
1
)))
// Turn map-side combine off and pass a wrong mergeCombine function. Should
// not see an exception because mergeCombine should not have been called.
val
aggregatorWithException
=
new
Aggregator
[
Int
,
Int
,
Int
](
(
v
:
Int
)
=>
v
,
_
+
_
,
ShuffleSuite
.
mergeCombineException
,
false
)
val
shuffledRdd1
=
new
ShuffledRDD
(
pairs
,
aggregatorWithException
,
new
HashPartitioner
(
2
))
assert
(
shuffledRdd1
.
collect
().
toSet
===
Set
((
1
,
8
),
(
2
,
1
)))
// Now run the same mergeCombine function with map-side combine on. We
// expect to see an exception thrown.
val
aggregatorWithException1
=
new
Aggregator
[
Int
,
Int
,
Int
](
(
v
:
Int
)
=>
v
,
_
+
_
,
ShuffleSuite
.
mergeCombineException
)
val
shuffledRdd2
=
new
ShuffledRDD
(
pairs
,
aggregatorWithException1
,
new
HashPartitioner
(
2
))
evaluating
{
shuffledRdd2
.
collect
()
}
should
produce
[
SparkException
]
}
}
object
ShuffleSuite
{
def
mergeCombineException
(
x
:
Int
,
y
:
Int
)
:
Int
=
{
throw
new
SparkException
(
"Exception for map-side combine."
)
x
+
y
}
}
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