Skip to content

Commit 9db0abc

Browse files
committed
Avoid writing empty files in BypassMergeSortShuffleWriter
1 parent 57c2cb4 commit 9db0abc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/src/main/java/org/apache/spark/shuffle/sort/BypassMergeSortShuffleWriter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void insertAll(Iterator<Product2<K, V>> records) throws IOException {
108108
final File file = tempShuffleBlockIdPlusFile._2();
109109
final BlockId blockId = tempShuffleBlockIdPlusFile._1();
110110
partitionWriters[i] =
111-
blockManager.getDiskWriter(blockId, file, serInstance, fileBufferSize, writeMetrics).open();
111+
blockManager.getDiskWriter(blockId, file, serInstance, fileBufferSize, writeMetrics);
112112
}
113113
// Creating the file to write to and creating a disk writer both involve interacting with
114114
// the disk, and can take a long time in aggregate when we open many files, so should be
@@ -143,6 +143,9 @@ public long[] writePartitionedFile(
143143
boolean threwException = true;
144144
try {
145145
for (int i = 0; i < numPartitions; i++) {
146+
if (partitionWriters[i].fileSegment().length() == 0) {
147+
continue;
148+
}
146149
final FileInputStream in = new FileInputStream(partitionWriters[i].fileSegment().file());
147150
boolean copyThrewException = true;
148151
try {

0 commit comments

Comments
 (0)