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
13f6900e
Commit
13f6900e
authored
13 years ago
by
Matei Zaharia
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:mesos/spark
parents
c7d6f1a6
c5be7d2b
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
bagel/src/test/scala/bagel/BagelSuite.scala
+21
-23
21 additions, 23 deletions
bagel/src/test/scala/bagel/BagelSuite.scala
with
21 additions
and
23 deletions
bagel/src/test/scala/bagel/BagelSuite.scala
+
21
−
23
View file @
13f6900e
...
...
@@ -10,45 +10,43 @@ import scala.collection.mutable.ArrayBuffer
import
spark._
import
spark.bagel.Bagel._
class
TestVertex
(
val
id
:
String
,
val
active
:
Boolean
,
val
age
:
Int
)
extends
Vertex
with
Serializable
class
TestMessage
(
val
targetId
:
String
)
extends
Message
with
Serializable
class
TestVertex
(
val
active
:
Boolean
,
val
age
:
Int
)
extends
Vertex
with
Serializable
class
TestMessage
(
val
targetId
:
String
)
extends
Message
[
String
]
with
Serializable
class
BagelSuite
extends
FunSuite
with
Assertions
{
test
(
"halting by voting"
)
{
val
sc
=
new
SparkContext
(
"local"
,
"test"
)
val
verts
=
sc
.
parallelize
(
Array
(
"a"
,
"b"
,
"c"
,
"d"
).
map
(
id
=>
(
id
,
new
TestVertex
(
id
,
true
,
0
))))
val
verts
=
sc
.
parallelize
(
Array
(
"a"
,
"b"
,
"c"
,
"d"
).
map
(
id
=>
(
id
,
new
TestVertex
(
true
,
0
))))
val
msgs
=
sc
.
parallelize
(
Array
[(
String
,
TestMessage
)]())
val
numSupersteps
=
5
val
result
=
Bagel
.
run
(
sc
,
verts
,
msgs
)()(
addAggregatorArg
{
(
self
:
TestVertex
,
msgs
:
Option
[
Array
Buffer
[
TestMessage
]],
superstep
:
Int
)
=>
(
new
TestVertex
(
self
.
id
,
superstep
<
numSupersteps
-
1
,
self
.
age
+
1
),
Array
[
TestMessage
]())
}
)
for
(
vert
<-
result
.
collect
)
Bagel
.
run
(
sc
,
verts
,
msgs
,
sc
.
defaultParallelism
)
{
(
self
:
TestVertex
,
msgs
:
Option
[
Array
[
TestMessage
]],
superstep
:
Int
)
=>
(
new
TestVertex
(
superstep
<
numSupersteps
-
1
,
self
.
age
+
1
),
Array
[
TestMessage
]())
}
for
(
(
id
,
vert
)
<-
result
.
collect
)
assert
(
vert
.
age
===
numSupersteps
)
sc
.
stop
()
}
test
(
"halting by message silence"
)
{
val
sc
=
new
SparkContext
(
"local"
,
"test"
)
val
verts
=
sc
.
parallelize
(
Array
(
"a"
,
"b"
,
"c"
,
"d"
).
map
(
id
=>
(
id
,
new
TestVertex
(
id
,
false
,
0
))))
val
verts
=
sc
.
parallelize
(
Array
(
"a"
,
"b"
,
"c"
,
"d"
).
map
(
id
=>
(
id
,
new
TestVertex
(
false
,
0
))))
val
msgs
=
sc
.
parallelize
(
Array
(
"a"
->
new
TestMessage
(
"a"
)))
val
numSupersteps
=
5
val
result
=
Bagel
.
run
(
sc
,
verts
,
msgs
)()(
addAggregatorArg
{
(
self
:
TestVertex
,
msgs
:
Option
[
Array
Buffer
[
TestMessage
]],
superstep
:
Int
)
=>
val
msgsOut
=
msgs
match
{
case
Some
(
ms
)
if
(
superstep
<
numSupersteps
-
1
)
=>
ms
case
_
=>
new
Array
Buffer
[
TestMessage
]()
}
(
new
TestVertex
(
self
.
id
,
self
.
active
,
self
.
age
+
1
),
msgsOut
)
}
)
for
(
vert
<-
result
.
collect
)
Bagel
.
run
(
sc
,
verts
,
msgs
,
sc
.
defaultParallelism
)
{
(
self
:
TestVertex
,
msgs
:
Option
[
Array
[
TestMessage
]],
superstep
:
Int
)
=>
val
msgsOut
=
msgs
match
{
case
Some
(
ms
)
if
(
superstep
<
numSupersteps
-
1
)
=>
ms
case
_
=>
Array
[
TestMessage
]()
}
(
new
TestVertex
(
self
.
active
,
self
.
age
+
1
),
msgsOut
)
}
for
(
(
id
,
vert
)
<-
result
.
collect
)
assert
(
vert
.
age
===
numSupersteps
)
sc
.
stop
()
}
...
...
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