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
59195c68
Commit
59195c68
authored
12 years ago
by
Josh Rosen
Browse files
Options
Downloads
Patches
Plain Diff
Update PySpark for compatibility with TaskContext.
parent
c5cee53f
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/api/python/PythonRDD.scala
+5
-8
5 additions, 8 deletions
core/src/main/scala/spark/api/python/PythonRDD.scala
pyspark/pyspark/rdd.py
+2
-1
2 additions, 1 deletion
pyspark/pyspark/rdd.py
with
7 additions
and
9 deletions
core/src/main/scala/spark/api/python/PythonRDD.scala
+
5
−
8
View file @
59195c68
...
...
@@ -8,10 +8,7 @@ import scala.io.Source
import
spark.api.java.
{
JavaSparkContext
,
JavaPairRDD
,
JavaRDD
}
import
spark.broadcast.Broadcast
import
spark.SparkEnv
import
spark.Split
import
spark.RDD
import
spark.OneToOneDependency
import
spark._
import
spark.rdd.PipedRDD
...
...
@@ -34,7 +31,7 @@ private[spark] class PythonRDD[T: ClassManifest](
override
val
partitioner
=
if
(
preservePartitoning
)
parent
.
partitioner
else
None
override
def
compute
(
split
:
Split
)
:
Iterator
[
Array
[
Byte
]]
=
{
override
def
compute
(
split
:
Split
,
context
:
TaskContext
)
:
Iterator
[
Array
[
Byte
]]
=
{
val
SPARK_HOME
=
new
ProcessBuilder
().
environment
().
get
(
"SPARK_HOME"
)
val
pb
=
new
ProcessBuilder
(
Seq
(
pythonExec
,
SPARK_HOME
+
"/pyspark/pyspark/worker.py"
))
...
...
@@ -74,7 +71,7 @@ private[spark] class PythonRDD[T: ClassManifest](
out
.
println
(
elem
)
}
out
.
flush
()
for
(
elem
<-
parent
.
iterator
(
split
))
{
for
(
elem
<-
parent
.
iterator
(
split
,
context
))
{
PythonRDD
.
writeAsPickle
(
elem
,
dOut
)
}
dOut
.
flush
()
...
...
@@ -123,8 +120,8 @@ private class PairwiseRDD(prev: RDD[Array[Byte]]) extends
RDD
[(
Array
[
Byte
]
,
Array
[
Byte
])](
prev
.
context
)
{
override
def
splits
=
prev
.
splits
override
val
dependencies
=
List
(
new
OneToOneDependency
(
prev
))
override
def
compute
(
split
:
Split
)
=
prev
.
iterator
(
split
).
grouped
(
2
).
map
{
override
def
compute
(
split
:
Split
,
context
:
TaskContext
)
=
prev
.
iterator
(
split
,
context
).
grouped
(
2
).
map
{
case
Seq
(
a
,
b
)
=>
(
a
,
b
)
case
x
=>
throw
new
Exception
(
"PairwiseRDD: unexpected value: "
+
x
)
}
...
...
This diff is collapsed.
Click to expand it.
pyspark/pyspark/rdd.py
+
2
−
1
View file @
59195c68
...
...
@@ -335,9 +335,10 @@ class RDD(object):
"""
items
=
[]
splits
=
self
.
_jrdd
.
splits
()
taskContext
=
self
.
ctx
.
jvm
.
spark
.
TaskContext
(
0
,
0
,
0
)
while
len
(
items
)
<
num
and
splits
:
split
=
splits
.
pop
(
0
)
iterator
=
self
.
_jrdd
.
iterator
(
split
)
iterator
=
self
.
_jrdd
.
iterator
(
split
,
taskContext
)
items
.
extend
(
self
.
_collect_iterator_through_file
(
iterator
))
return
items
[:
num
]
...
...
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