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
acc4aa1f
Commit
acc4aa1f
authored
11 years ago
by
Reynold Xin
Browse files
Options
Downloads
Patches
Plain Diff
Added a test for sorting using MutablePair's.
parent
71d705a6
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
+18
-2
18 additions, 2 deletions
core/src/test/scala/spark/ShuffleSuite.scala
with
18 additions
and
2 deletions
core/src/test/scala/spark/ShuffleSuite.scala
+
18
−
2
View file @
acc4aa1f
...
...
@@ -20,9 +20,10 @@ package spark
import
org.scalatest.FunSuite
import
org.scalatest.matchers.ShouldMatchers
import
spark.rdd.ShuffledRDD
import
spark.SparkContext._
import
spark.ShuffleSuite.NonJavaSerializableClass
import
spark.rdd.OrderedRDDFunctions
import
spark.rdd.ShuffledRDD
import
spark.util.MutablePair
...
...
@@ -137,12 +138,27 @@ class ShuffleSuite extends FunSuite with ShouldMatchers with LocalSparkContext {
sc
=
new
SparkContext
(
"local-cluster[2,1,512]"
,
"test"
)
def
p
[
T1
,
T2
](
_1
:
T1
,
_2
:
T2
)
=
MutablePair
(
_1
,
_2
)
val
data
=
Array
(
p
(
1
,
1
),
p
(
1
,
2
),
p
(
1
,
3
),
p
(
2
,
1
))
val
pairs
:
RDD
[
MutablePair
[
Int
,
Int
]]
=
sc
.
parallelize
(
data
)
val
pairs
:
RDD
[
MutablePair
[
Int
,
Int
]]
=
sc
.
parallelize
(
data
,
2
)
val
results
=
new
ShuffledRDD
[
Int
,
Int
,
MutablePair
[
Int
,
Int
]](
pairs
,
new
HashPartitioner
(
2
))
.
collect
()
data
.
foreach
{
pair
=>
results
should
contain
(
pair
)
}
}
test
(
"sorting using mutable pairs"
)
{
// This is not in SortingSuite because of the local cluster setup.
// Use a local cluster with 2 processes to make sure there are both local and remote blocks
sc
=
new
SparkContext
(
"local-cluster[2,1,512]"
,
"test"
)
def
p
[
T1
,
T2
](
_1
:
T1
,
_2
:
T2
)
=
MutablePair
(
_1
,
_2
)
val
data
=
Array
(
p
(
1
,
11
),
p
(
3
,
33
),
p
(
100
,
100
),
p
(
2
,
22
))
val
pairs
:
RDD
[
MutablePair
[
Int
,
Int
]]
=
sc
.
parallelize
(
data
,
2
)
val
results
=
new
OrderedRDDFunctions
[
Int
,
Int
,
MutablePair
[
Int
,
Int
]](
pairs
)
.
sortByKey
().
collect
()
results
(
0
)
should
be
(
p
(
1
,
11
))
results
(
1
)
should
be
(
p
(
2
,
22
))
results
(
2
)
should
be
(
p
(
3
,
33
))
results
(
3
)
should
be
(
p
(
100
,
100
))
}
}
object
ShuffleSuite
{
...
...
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