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
7341de0d
Commit
7341de0d
authored
12 years ago
by
Matei Zaharia
Browse files
Options
Downloads
Plain Diff
Merge pull request #475 from JoshRosen/spark-668
Remove hack workaround for SPARK-668
parents
fcf7fa84
e9fb2542
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/java/JavaRDDLike.scala
+7
-6
7 additions, 6 deletions
core/src/main/scala/spark/api/java/JavaRDDLike.scala
core/src/main/scala/spark/api/java/PairFlatMapWorkaround.java
+0
-20
0 additions, 20 deletions
.../src/main/scala/spark/api/java/PairFlatMapWorkaround.java
with
7 additions
and
26 deletions
core/src/main/scala/spark/api/java/JavaRDDLike.scala
+
7
−
6
View file @
7341de0d
...
...
@@ -12,7 +12,7 @@ import spark.storage.StorageLevel
import
com.google.common.base.Optional
trait
JavaRDDLike
[
T
,
This
<:
JavaRDDLike
[
T
,
This
]]
extends
PairFlatMapWorkaround
[
T
]
{
trait
JavaRDDLike
[
T
,
This
<:
JavaRDDLike
[
T
,
This
]]
extends
Serializable
{
def
wrapRDD
(
rdd
:
RDD
[
T
])
:
This
implicit
val
classManifest
:
ClassManifest
[
T
]
...
...
@@ -82,12 +82,13 @@ trait JavaRDDLike[T, This <: JavaRDDLike[T, This]] extends PairFlatMapWorkaround
}
/**
* Part of the workaround for SPARK-668; called in PairFlatMapWorkaround.java.
* Return a new RDD by first applying a function to all elements of this
* RDD, and then flattening the results.
*/
private
[
spark
]
def
doF
latMap
[
K
,
V
](
f
:
PairFlatMapFunction
[
T
,
K
,
V
])
:
JavaPairRDD
[
K
,
V
]
=
{
def
f
latMap
[
K
2
,
V
2
](
f
:
PairFlatMapFunction
[
T
,
K
2
,
V
2
])
:
JavaPairRDD
[
K
2
,
V
2
]
=
{
import
scala.collection.JavaConverters._
def
fn
=
(
x
:
T
)
=>
f
.
apply
(
x
).
asScala
def
cm
=
implicitly
[
ClassManifest
[
AnyRef
]].
asInstanceOf
[
ClassManifest
[
Tuple2
[
K
,
V
]]]
def
cm
=
implicitly
[
ClassManifest
[
AnyRef
]].
asInstanceOf
[
ClassManifest
[
Tuple2
[
K
2
,
V
2
]]]
JavaPairRDD
.
fromRDD
(
rdd
.
flatMap
(
fn
)(
cm
))(
f
.
keyType
(),
f
.
valueType
())
}
...
...
@@ -110,8 +111,8 @@ trait JavaRDDLike[T, This <: JavaRDDLike[T, This]] extends PairFlatMapWorkaround
/**
* Return a new RDD by applying a function to each partition of this RDD.
*/
def
mapPartitions
[
K
,
V
](
f
:
PairFlatMapFunction
[
java.util.Iterator
[
T
]
,
K
,
V
])
:
JavaPairRDD
[
K
,
V
]
=
{
def
mapPartitions
[
K
2
,
V
2
](
f
:
PairFlatMapFunction
[
java.util.Iterator
[
T
]
,
K
2
,
V
2
])
:
JavaPairRDD
[
K
2
,
V
2
]
=
{
def
fn
=
(
x
:
Iterator
[
T
])
=>
asScalaIterator
(
f
.
apply
(
asJavaIterator
(
x
)).
iterator
())
JavaPairRDD
.
fromRDD
(
rdd
.
mapPartitions
(
fn
))(
f
.
keyType
(),
f
.
valueType
())
}
...
...
This diff is collapsed.
Click to expand it.
core/src/main/scala/spark/api/java/PairFlatMapWorkaround.java
deleted
100644 → 0
+
0
−
20
View file @
fcf7fa84
package
spark.api.java
;
import
spark.api.java.JavaPairRDD
;
import
spark.api.java.JavaRDDLike
;
import
spark.api.java.function.PairFlatMapFunction
;
import
java.io.Serializable
;
/**
* Workaround for SPARK-668.
*/
class
PairFlatMapWorkaround
<
T
>
implements
Serializable
{
/**
* Return a new RDD by first applying a function to all elements of this
* RDD, and then flattening the results.
*/
public
<
K
,
V
>
JavaPairRDD
<
K
,
V
>
flatMap
(
PairFlatMapFunction
<
T
,
K
,
V
>
f
)
{
return
((
JavaRDDLike
<
T
,
?>)
this
).
doFlatMap
(
f
);
}
}
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