gczsjdy commented on a change in pull request #25304:
[SPARK-28570][CORE][SHUFFLE] Make UnsafeShuffleWriter use the new API.
URL: https://github.com/apache/spark/pull/25304#discussion_r314931775
##########
File path:
core/src/main/java/org/apache/spark/shuffle/sort/UnsafeShuffleWriter.java
##########
@@ -273,57 +259,93 @@ void forceSorterToSpill() throws IOException {
*
* @return the partition lengths in the merged file.
*/
- private long[] mergeSpills(SpillInfo[] spills,
- ShuffleMapOutputWriter mapWriter) throws IOException {
+ private long[] mergeSpills(SpillInfo[] spills) throws IOException {
+ long[] partitionLengths;
+ if (spills.length == 0) {
+ final ShuffleMapOutputWriter mapWriter = shuffleExecutorComponents
+ .createMapOutputWriter(
+ shuffleId,
+ mapId,
+ taskContext.taskAttemptId(),
+ partitioner.numPartitions());
+ mapWriter.commitAllPartitions();
+ return new long[partitioner.numPartitions()];
+ } else if (spills.length == 1) {
+ Optional<SingleFileShuffleMapOutputWriter> maybeSingleFileWriter =
+ shuffleExecutorComponents.createSingleFileMapOutputWriter(
+ shuffleId, mapId, taskContext.taskAttemptId());
+ if (maybeSingleFileWriter.isPresent()) {
+ // Here, we don't need to perform any metrics updates because the
bytes written to this
+ // output file would have already been counted as shuffle bytes
written.
Review comment:
@squito I think this `SingleSpillShuffleMapOutputWriter` can be pretty
useful, it may avoid some byte-to-byte read/write, instead the custom store can
have implementation with more performant.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]