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
5013fb64
Commit
5013fb64
authored
11 years ago
by
Binh Nguyen
Browse files
Options
Downloads
Patches
Plain Diff
Expose numPartitions parameter in JavaPairRDD.sortByKey()
This change make Java and Scala API on sortByKey() the same.
parent
6169fe14
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/src/main/scala/org/apache/spark/api/java/JavaPairRDD.scala
+10
-2
10 additions, 2 deletions
...rc/main/scala/org/apache/spark/api/java/JavaPairRDD.scala
with
10 additions
and
2 deletions
core/src/main/scala/org/apache/spark/api/java/JavaPairRDD.scala
+
10
−
2
View file @
5013fb64
...
...
@@ -583,12 +583,20 @@ class JavaPairRDD[K, V](val rdd: RDD[(K, V)])(implicit val kManifest: ClassManif
* (in the `save` case, they will be written to multiple `part-X` files in the filesystem, in
* order of the keys).
*/
def
sortByKey
(
comp
:
Comparator
[
K
],
ascending
:
Boolean
)
:
JavaPairRDD
[
K
,
V
]
=
{
def
sortByKey
(
comp
:
Comparator
[
K
],
ascending
:
Boolean
)
:
JavaPairRDD
[
K
,
V
]
=
sortByKey
(
comp
,
ascending
,
rdd
.
partitions
.
size
)
/**
* Sort the RDD by key, so that each partition contains a sorted range of the elements. Calling
* `collect` or `save` on the resulting RDD will return or output an ordered list of records
* (in the `save` case, they will be written to multiple `part-X` files in the filesystem, in
* order of the keys).
*/
def
sortByKey
(
comp
:
Comparator
[
K
],
ascending
:
Boolean
,
numPartitions
:
Int
)
:
JavaPairRDD
[
K
,
V
]
=
{
class
KeyOrdering
(
val
a
:
K
)
extends
Ordered
[
K
]
{
override
def
compare
(
b
:
K
)
=
comp
.
compare
(
a
,
b
)
}
implicit
def
toOrdered
(
x
:
K
)
:
Ordered
[
K
]
=
new
KeyOrdering
(
x
)
fromRDD
(
new
OrderedRDDFunctions
[
K
,
V
,
(
K
,
V
)](
rdd
).
sortByKey
(
ascending
))
fromRDD
(
new
OrderedRDDFunctions
[
K
,
V
,
(
K
,
V
)](
rdd
).
sortByKey
(
ascending
,
numPartitions
))
}
/**
...
...
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