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
d9ea6d69
Commit
d9ea6d69
authored
14 years ago
by
Matei Zaharia
Browse files
Options
Downloads
Patches
Plain Diff
Create output files one by one instead of at the same time in the map
phase of DfsShuffle.
parent
16ff4dc0
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
src/scala/spark/DfsShuffle.scala
+11
-12
11 additions, 12 deletions
src/scala/spark/DfsShuffle.scala
with
11 additions
and
12 deletions
src/scala/spark/DfsShuffle.scala
+
11
−
12
View file @
d9ea6d69
...
...
@@ -38,26 +38,25 @@ extends Logging
numberedSplitRdd
.
foreach
((
pair
:
(
Int
,
Iterator
[(
K
,
V
)]))
=>
{
val
myIndex
=
pair
.
_1
val
myIterator
=
pair
.
_2
val
combiners
=
new
HashMap
[
K
,
C
]
val
buckets
=
Array
.
tabulate
(
numOutputSplits
)(
_
=
>
new
HashMap
[
K
,
C
]
)
for
((
k
,
v
)
<-
myIterator
)
{
combiners
(
k
)
=
combiners
.
get
(
k
)
match
{
var
bucketId
=
k
.
hashCode
%
numOutputSplits
if
(
bucketId
<
0
)
{
// Fix bucket ID if hash code was negative
bucketId
+=
numOutputSplits
}
val
bucket
=
buckets
(
bucketId
)
bucket
(
k
)
=
bucket
.
get
(
k
)
match
{
case
Some
(
c
)
=>
mergeValue
(
c
,
v
)
case
None
=>
createCombiner
(
v
)
}
}
val
fs
=
DfsShuffle
.
getFileSystem
()
val
outputStreams
=
(
0
until
numOutputSplits
)
.
map
(
i
=>
{
for
(
i
<-
0
until
numOutputSplits
)
{
val
path
=
new
Path
(
dir
,
"%d-to-%d"
.
format
(
myIndex
,
i
))
new
ObjectOutputStream
(
fs
.
create
(
path
,
true
))
}).
toArray
for
((
k
,
c
)
<-
combiners
)
{
var
bucket
=
k
.
hashCode
%
numOutputSplits
if
(
bucket
<
0
)
{
bucket
+=
numOutputSplits
}
outputStreams
(
bucket
).
writeObject
((
k
,
c
))
val
out
=
new
ObjectOutputStream
(
fs
.
create
(
path
,
true
))
buckets
(
i
).
foreach
(
pair
=>
out
.
writeObject
(
pair
))
out
.
close
()
}
outputStreams
.
foreach
(
_
.
close
())
})
// Return an RDD that does each of the merges for a given partition
...
...
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