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
cb366774
Commit
cb366774
authored
11 years ago
by
Reynold Xin
Browse files
Options
Downloads
Plain Diff
Merge pull request #738 from harsha2010/pruning
Fix bug in Partition Pruning.
parents
f3cf0949
392d7474
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/scala/spark/rdd/PartitionPruningRDD.scala
+3
-2
3 additions, 2 deletions
core/src/main/scala/spark/rdd/PartitionPruningRDD.scala
core/src/test/scala/spark/PartitionPruningRDDSuite.scala
+28
-0
28 additions, 0 deletions
core/src/test/scala/spark/PartitionPruningRDDSuite.scala
with
31 additions
and
2 deletions
core/src/main/scala/spark/rdd/PartitionPruningRDD.scala
+
3
−
2
View file @
cb366774
...
@@ -33,8 +33,9 @@ class PruneDependency[T](rdd: RDD[T], @transient partitionFilterFunc: Int => Boo
...
@@ -33,8 +33,9 @@ class PruneDependency[T](rdd: RDD[T], @transient partitionFilterFunc: Int => Boo
extends
NarrowDependency
[
T
](
rdd
)
{
extends
NarrowDependency
[
T
](
rdd
)
{
@transient
@transient
val
partitions
:
Array
[
Partition
]
=
rdd
.
partitions
.
filter
(
s
=>
partitionFilterFunc
(
s
.
index
))
val
partitions
:
Array
[
Partition
]
=
rdd
.
partitions
.
zipWithIndex
.
zipWithIndex
.
map
{
case
(
split
,
idx
)
=>
new
PartitionPruningRDDPartition
(
idx
,
split
)
:
Partition
}
.
filter
(
s
=>
partitionFilterFunc
(
s
.
_2
))
.
map
{
case
(
split
,
idx
)
=>
new
PartitionPruningRDDPartition
(
idx
,
split
)
:
Partition
}
override
def
getParents
(
partitionId
:
Int
)
=
List
(
partitions
(
partitionId
).
index
)
override
def
getParents
(
partitionId
:
Int
)
=
List
(
partitions
(
partitionId
).
index
)
}
}
...
...
This diff is collapsed.
Click to expand it.
core/src/test/scala/spark/PartitionPruningRDDSuite.scala
0 → 100644
+
28
−
0
View file @
cb366774
package
spark
import
org.scalatest.FunSuite
import
spark.SparkContext._
import
spark.rdd.PartitionPruningRDD
class
PartitionPruningRDDSuite
extends
FunSuite
with
SharedSparkContext
{
test
(
"Pruned Partitions inherit locality prefs correctly"
)
{
class
TestPartition
(
i
:
Int
)
extends
Partition
{
def
index
=
i
}
val
rdd
=
new
RDD
[
Int
](
sc
,
Nil
)
{
override
protected
def
getPartitions
=
{
Array
[
Partition
](
new
TestPartition
(
1
),
new
TestPartition
(
2
),
new
TestPartition
(
3
))
}
def
compute
(
split
:
Partition
,
context
:
TaskContext
)
=
{
Iterator
()}
}
val
prunedRDD
=
PartitionPruningRDD
.
create
(
rdd
,
{
x
=>
if
(
x
==
2
)
true
else
false
})
val
p
=
prunedRDD
.
partitions
(
0
)
assert
(
p
.
index
==
2
)
assert
(
prunedRDD
.
partitions
.
length
==
1
)
}
}
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