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
41436785
Commit
41436785
authored
12 years ago
by
Josh Rosen
Browse files
Options
Downloads
Patches
Plain Diff
Fix minor bugs in Python API examples.
parent
bff6a463
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
pyspark/pyspark/examples/pi.py
+1
-1
1 addition, 1 deletion
pyspark/pyspark/examples/pi.py
pyspark/pyspark/examples/tc.py
+4
-4
4 additions, 4 deletions
pyspark/pyspark/examples/tc.py
with
5 additions
and
5 deletions
pyspark/pyspark/examples/pi.py
+
1
−
1
View file @
41436785
...
...
@@ -9,7 +9,7 @@ if __name__ == "__main__":
print
>>
sys
.
stderr
,
\
"
Usage: PythonPi <host> [<slices>]
"
exit
(
-
1
)
sc
=
SparkContext
(
sys
.
argv
[
1
],
"
Python
KMeans
"
)
sc
=
SparkContext
(
sys
.
argv
[
1
],
"
Python
Pi
"
)
slices
=
int
(
sys
.
argv
[
2
])
if
len
(
sys
.
argv
)
>
2
else
2
n
=
100000
*
slices
def
f
(
_
):
...
...
This diff is collapsed.
Click to expand it.
pyspark/pyspark/examples/tc.py
+
4
−
4
View file @
41436785
...
...
@@ -22,9 +22,9 @@ if __name__ == "__main__":
print
>>
sys
.
stderr
,
\
"
Usage: PythonTC <host> [<slices>]
"
exit
(
-
1
)
sc
=
SparkContext
(
sys
.
argv
[
1
],
"
Python
KMeans
"
)
sc
=
SparkContext
(
sys
.
argv
[
1
],
"
Python
TC
"
)
slices
=
sys
.
argv
[
2
]
if
len
(
sys
.
argv
)
>
2
else
2
tc
=
sc
.
parallelize
Pairs
(
generateGraph
(),
slices
).
cache
()
tc
=
sc
.
parallelize
(
generateGraph
(),
slices
).
cache
()
# Linear transitive closure: each round grows paths by one edge,
# by joining the graph's edges with the already-discovered paths.
...
...
@@ -32,7 +32,7 @@ if __name__ == "__main__":
# the graph to obtain the path (x, z).
# Because join() joins on keys, the edges are stored in reversed order.
edges
=
tc
.
map
Pairs
(
lambda
(
x
,
y
):
(
y
,
x
))
edges
=
tc
.
map
(
lambda
(
x
,
y
):
(
y
,
x
))
oldCount
=
0L
nextCount
=
tc
.
count
()
...
...
@@ -40,7 +40,7 @@ if __name__ == "__main__":
oldCount
=
nextCount
# Perform the join, obtaining an RDD of (y, (z, x)) pairs,
# then project the result to obtain the new (x, z) paths.
new_edges
=
tc
.
join
(
edges
).
map
Pairs
(
lambda
(
_
,
(
a
,
b
)):
(
b
,
a
))
new_edges
=
tc
.
join
(
edges
).
map
(
lambda
(
_
,
(
a
,
b
)):
(
b
,
a
))
tc
=
tc
.
union
(
new_edges
).
distinct
().
cache
()
nextCount
=
tc
.
count
()
if
nextCount
==
oldCount
:
...
...
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