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
c1507afc
Commit
c1507afc
authored
11 years ago
by
Ankur Dave
Browse files
Options
Downloads
Patches
Plain Diff
Support preservesPartitioning in RDD.zipPartitions
parent
086b097e
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/org/apache/spark/rdd/RDD.scala
+18
-3
18 additions, 3 deletions
core/src/main/scala/org/apache/spark/rdd/RDD.scala
core/src/main/scala/org/apache/spark/rdd/ZippedPartitionsRDD.scala
+14
-7
14 additions, 7 deletions
...main/scala/org/apache/spark/rdd/ZippedPartitionsRDD.scala
with
32 additions
and
10 deletions
core/src/main/scala/org/apache/spark/rdd/RDD.scala
+
18
−
3
View file @
c1507afc
...
...
@@ -545,20 +545,35 @@ abstract class RDD[T: ClassManifest](
* *same number of partitions*, but does *not* require them to have the same number
* of elements in each partition.
*/
def
zipPartitions
[
B:
ClassManifest
,
V:
ClassManifest
]
(
rdd2
:
RDD
[
B
],
preservesPartitioning
:
Boolean
)
(
f
:
(
Iterator
[
T
],
Iterator
[
B
])
=>
Iterator
[
V
])
:
RDD
[
V
]
=
new
ZippedPartitionsRDD2
(
sc
,
sc
.
clean
(
f
),
this
,
rdd2
,
preservesPartitioning
)
def
zipPartitions
[
B:
ClassManifest
,
V:
ClassManifest
]
(
rdd2
:
RDD
[
B
])
(
f
:
(
Iterator
[
T
],
Iterator
[
B
])
=>
Iterator
[
V
])
:
RDD
[
V
]
=
new
ZippedPartitionsRDD2
(
sc
,
sc
.
clean
(
f
),
this
,
rdd2
)
new
ZippedPartitionsRDD2
(
sc
,
sc
.
clean
(
f
),
this
,
rdd2
,
false
)
def
zipPartitions
[
B:
ClassManifest
,
C:
ClassManifest
,
V:
ClassManifest
]
(
rdd2
:
RDD
[
B
],
rdd3
:
RDD
[
C
],
preservesPartitioning
:
Boolean
)
(
f
:
(
Iterator
[
T
],
Iterator
[
B
],
Iterator
[
C
])
=>
Iterator
[
V
])
:
RDD
[
V
]
=
new
ZippedPartitionsRDD3
(
sc
,
sc
.
clean
(
f
),
this
,
rdd2
,
rdd3
,
preservesPartitioning
)
def
zipPartitions
[
B:
ClassManifest
,
C:
ClassManifest
,
V:
ClassManifest
]
(
rdd2
:
RDD
[
B
],
rdd3
:
RDD
[
C
])
(
f
:
(
Iterator
[
T
],
Iterator
[
B
],
Iterator
[
C
])
=>
Iterator
[
V
])
:
RDD
[
V
]
=
new
ZippedPartitionsRDD3
(
sc
,
sc
.
clean
(
f
),
this
,
rdd2
,
rdd3
)
new
ZippedPartitionsRDD3
(
sc
,
sc
.
clean
(
f
),
this
,
rdd2
,
rdd3
,
false
)
def
zipPartitions
[
B:
ClassManifest
,
C:
ClassManifest
,
D:
ClassManifest
,
V:
ClassManifest
]
(
rdd2
:
RDD
[
B
],
rdd3
:
RDD
[
C
],
rdd4
:
RDD
[
D
],
preservesPartitioning
:
Boolean
)
(
f
:
(
Iterator
[
T
],
Iterator
[
B
],
Iterator
[
C
],
Iterator
[
D
])
=>
Iterator
[
V
])
:
RDD
[
V
]
=
new
ZippedPartitionsRDD4
(
sc
,
sc
.
clean
(
f
),
this
,
rdd2
,
rdd3
,
rdd4
,
preservesPartitioning
)
def
zipPartitions
[
B:
ClassManifest
,
C:
ClassManifest
,
D:
ClassManifest
,
V:
ClassManifest
]
(
rdd2
:
RDD
[
B
],
rdd3
:
RDD
[
C
],
rdd4
:
RDD
[
D
])
(
f
:
(
Iterator
[
T
],
Iterator
[
B
],
Iterator
[
C
],
Iterator
[
D
])
=>
Iterator
[
V
])
:
RDD
[
V
]
=
new
ZippedPartitionsRDD4
(
sc
,
sc
.
clean
(
f
),
this
,
rdd2
,
rdd3
,
rdd4
)
new
ZippedPartitionsRDD4
(
sc
,
sc
.
clean
(
f
),
this
,
rdd2
,
rdd3
,
rdd4
,
false
)
// Actions (launch a job to return a value to the user program)
...
...
This diff is collapsed.
Click to expand it.
core/src/main/scala/org/apache/spark/rdd/ZippedPartitionsRDD.scala
+
14
−
7
View file @
c1507afc
...
...
@@ -39,9 +39,13 @@ private[spark] class ZippedPartitionsPartition(
abstract
class
ZippedPartitionsBaseRDD
[
V:
ClassManifest
](
sc
:
SparkContext
,
var
rdds
:
Seq
[
RDD
[
_
]])
var
rdds
:
Seq
[
RDD
[
_
]],
preservesPartitioning
:
Boolean
=
false
)
extends
RDD
[
V
](
sc
,
rdds
.
map
(
x
=>
new
OneToOneDependency
(
x
)))
{
override
val
partitioner
=
if
(
preservesPartitioning
)
firstParent
[
Any
].
partitioner
else
None
override
def
getPartitions
:
Array
[
Partition
]
=
{
val
sizes
=
rdds
.
map
(
x
=>
x
.
partitions
.
size
)
if
(!
sizes
.
forall
(
x
=>
x
==
sizes
(
0
)))
{
...
...
@@ -76,8 +80,9 @@ class ZippedPartitionsRDD2[A: ClassManifest, B: ClassManifest, V: ClassManifest]
sc
:
SparkContext
,
f
:
(
Iterator
[
A
],
Iterator
[
B
])
=>
Iterator
[
V
],
var
rdd1
:
RDD
[
A
],
var
rdd2
:
RDD
[
B
])
extends
ZippedPartitionsBaseRDD
[
V
](
sc
,
List
(
rdd1
,
rdd2
))
{
var
rdd2
:
RDD
[
B
],
preservesPartitioning
:
Boolean
=
false
)
extends
ZippedPartitionsBaseRDD
[
V
](
sc
,
List
(
rdd1
,
rdd2
),
preservesPartitioning
)
{
override
def
compute
(
s
:
Partition
,
context
:
TaskContext
)
:
Iterator
[
V
]
=
{
val
partitions
=
s
.
asInstanceOf
[
ZippedPartitionsPartition
].
partitions
...
...
@@ -97,8 +102,9 @@ class ZippedPartitionsRDD3
f
:
(
Iterator
[
A
],
Iterator
[
B
],
Iterator
[
C
])
=>
Iterator
[
V
],
var
rdd1
:
RDD
[
A
],
var
rdd2
:
RDD
[
B
],
var
rdd3
:
RDD
[
C
])
extends
ZippedPartitionsBaseRDD
[
V
](
sc
,
List
(
rdd1
,
rdd2
,
rdd3
))
{
var
rdd3
:
RDD
[
C
],
preservesPartitioning
:
Boolean
=
false
)
extends
ZippedPartitionsBaseRDD
[
V
](
sc
,
List
(
rdd1
,
rdd2
,
rdd3
),
preservesPartitioning
)
{
override
def
compute
(
s
:
Partition
,
context
:
TaskContext
)
:
Iterator
[
V
]
=
{
val
partitions
=
s
.
asInstanceOf
[
ZippedPartitionsPartition
].
partitions
...
...
@@ -122,8 +128,9 @@ class ZippedPartitionsRDD4
var
rdd1
:
RDD
[
A
],
var
rdd2
:
RDD
[
B
],
var
rdd3
:
RDD
[
C
],
var
rdd4
:
RDD
[
D
])
extends
ZippedPartitionsBaseRDD
[
V
](
sc
,
List
(
rdd1
,
rdd2
,
rdd3
,
rdd4
))
{
var
rdd4
:
RDD
[
D
],
preservesPartitioning
:
Boolean
=
false
)
extends
ZippedPartitionsBaseRDD
[
V
](
sc
,
List
(
rdd1
,
rdd2
,
rdd3
,
rdd4
),
preservesPartitioning
)
{
override
def
compute
(
s
:
Partition
,
context
:
TaskContext
)
:
Iterator
[
V
]
=
{
val
partitions
=
s
.
asInstanceOf
[
ZippedPartitionsPartition
].
partitions
...
...
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