1818package org .apache .spark .shuffle .sort ;
1919
2020import java .nio .channels .Channels ;
21+ import java .util .Arrays ;
2122import java .util .Optional ;
2223import javax .annotation .Nullable ;
2324import java .io .*;
@@ -274,6 +275,8 @@ private long[] mergeSpills(SpillInfo[] spills) throws IOException {
274275 // Here, we don't need to perform any metrics updates because the bytes written to this
275276 // output file would have already been counted as shuffle bytes written.
276277 partitionLengths = spills [0 ].partitionLengths ;
278+ logger .debug ("Merge shuffle spills for mapId {} with length {}" , mapId ,
279+ partitionLengths .length );
277280 maybeSingleFileWriter .get ().transferMapSpillFile (spills [0 ].file , partitionLengths );
278281 } else {
279282 partitionLengths = mergeSpillsUsingStandardWriter (spills );
@@ -360,6 +363,7 @@ private void mergeSpillsWithFileStream(
360363 SpillInfo [] spills ,
361364 ShuffleMapOutputWriter mapWriter ,
362365 @ Nullable CompressionCodec compressionCodec ) throws IOException {
366+ logger .debug ("Merge shuffle spills with FileStream for mapId {}" , mapId );
363367 final int numPartitions = partitioner .numPartitions ();
364368 final InputStream [] spillInputStreams = new InputStream [spills .length ];
365369
@@ -369,6 +373,11 @@ private void mergeSpillsWithFileStream(
369373 spillInputStreams [i ] = new NioBufferedFileInputStream (
370374 spills [i ].file ,
371375 inputBufferSizeInBytes );
376+ // Only convert the partitionLengths when debug level is enabled.
377+ if (logger .isDebugEnabled ()) {
378+ logger .debug ("Partition lengths for mapId {} in Spill {}: {}" , mapId , i ,
379+ Arrays .toString (spills [i ].partitionLengths ));
380+ }
372381 }
373382 for (int partition = 0 ; partition < numPartitions ; partition ++) {
374383 boolean copyThrewException = true ;
@@ -431,6 +440,7 @@ private void mergeSpillsWithFileStream(
431440 private void mergeSpillsWithTransferTo (
432441 SpillInfo [] spills ,
433442 ShuffleMapOutputWriter mapWriter ) throws IOException {
443+ logger .debug ("Merge shuffle spills with TransferTo for mapId {}" , mapId );
434444 final int numPartitions = partitioner .numPartitions ();
435445 final FileChannel [] spillInputChannels = new FileChannel [spills .length ];
436446 final long [] spillInputChannelPositions = new long [spills .length ];
@@ -439,6 +449,11 @@ private void mergeSpillsWithTransferTo(
439449 try {
440450 for (int i = 0 ; i < spills .length ; i ++) {
441451 spillInputChannels [i ] = new FileInputStream (spills [i ].file ).getChannel ();
452+ // Only convert the partitionLengths when debug level is enabled.
453+ if (logger .isDebugEnabled ()) {
454+ logger .debug ("Partition lengths for mapId {} in Spill {}: {}" , mapId , i ,
455+ Arrays .toString (spills [i ].partitionLengths ));
456+ }
442457 }
443458 for (int partition = 0 ; partition < numPartitions ; partition ++) {
444459 boolean copyThrewException = true ;
0 commit comments