-
Notifications
You must be signed in to change notification settings - Fork 6
[SPARK-25299] Implement default version of the API for shuffle writes #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
7160ce3
460f0ea
96d1774
64fb327
996e903
3b9d33c
1f1c159
0737515
1ded83d
3353155
7a79bd9
9e3f05c
9f6230b
14df750
8cf80f7
46a0174
1325903
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,6 @@ public class DefaultShuffleMapOutputWriter implements ShuffleMapOutputWriter { | |
| private final long[] partitionLengths; | ||
| private final int bufferSize; | ||
| private int currPartitionId = 0; | ||
| private boolean successfulWrite = false; | ||
|
|
||
| private final File outputFile; | ||
| private final File outputTempFile; | ||
|
|
@@ -85,7 +84,7 @@ public ShufflePartitionWriter getNextPartitionWriter() throws IOException { | |
| public void commitAllPartitions() throws IOException { | ||
| cleanUp(); | ||
| blockResolver.writeIndexFileAndCommit(shuffleId, mapId, partitionLengths, outputTempFile); | ||
| if (!successfulWrite) { | ||
| if (!outputFile.exists()) { | ||
| if (!outputFile.getParentFile().isDirectory() && !outputFile.getParentFile().mkdirs()) { | ||
| throw new IOException( | ||
| String.format( | ||
|
|
@@ -102,13 +101,17 @@ public void commitAllPartitions() throws IOException { | |
|
|
||
| @Override | ||
| public void abort(Throwable error) throws IOException { | ||
| try { | ||
| cleanUp(); | ||
| } catch (Exception e) { | ||
| log.error("Unable to close appropriate underlying file stream", e); | ||
| } | ||
| if (!outputTempFile.delete() && outputTempFile.exists()) { | ||
|
||
| log.warn("Failed to delete temporary shuffle file at {}", outputTempFile.getAbsolutePath()); | ||
| } | ||
| if (!outputFile.delete() && outputFile.exists()) { | ||
| log.warn("Failed to delete outputshuffle file at {}", outputFile.getAbsolutePath()); | ||
| } | ||
| cleanUp(); | ||
| } | ||
|
|
||
| private void cleanUp() throws IOException { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're closing the streams, but I noticed that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Heh I am wrong... closing the fileOutputStream closes the channel :P |
||
|
|
@@ -143,16 +146,16 @@ private void initChannel() throws IOException { | |
| private class DefaultShufflePartitionWriter implements ShufflePartitionWriter { | ||
|
|
||
| private final int partitionId; | ||
| private DefaultShuffleBlockOutputStream stream = null; | ||
| private DefaultShuffleBlockByteChannel channel = null; | ||
| private PartitionWriterStream stream = null; | ||
| private PartitionWriterChannel channel = null; | ||
|
|
||
| private DefaultShufflePartitionWriter(int partitionId) { | ||
| this.partitionId = partitionId; | ||
| } | ||
|
|
||
| @Override | ||
| public OutputStream openStream() throws IOException { | ||
| stream = new DefaultShuffleBlockOutputStream(); | ||
| stream = new PartitionWriterStream(); | ||
| return stream; | ||
| } | ||
|
|
||
|
|
@@ -162,7 +165,7 @@ public long getLength() { | |
| try { | ||
| channel.close(); | ||
ifilonenko marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } catch (Exception e) { | ||
| log.error("Error with closing channel for partition", e); | ||
| throw new IllegalStateException("Attempting to close byte channel", e); | ||
| } | ||
| int length = channel.getCount(); | ||
| partitionLengths[partitionId] = length; | ||
|
|
@@ -171,7 +174,7 @@ public long getLength() { | |
| try { | ||
| stream.close(); | ||
| } catch (Exception e) { | ||
| log.error("Error with closing stream for partition", e); | ||
| throw new IllegalStateException("Attempting to close output stream", e); | ||
| } | ||
| int length = stream.getCount(); | ||
| partitionLengths[partitionId] = length; | ||
|
|
@@ -181,12 +184,12 @@ public long getLength() { | |
|
|
||
| @Override | ||
| public WritableByteChannel openChannel() throws IOException { | ||
| channel = new DefaultShuffleBlockByteChannel(); | ||
| channel = new PartitionWriterChannel(); | ||
| return channel; | ||
| } | ||
| } | ||
|
|
||
| private class DefaultShuffleBlockOutputStream extends OutputStream { | ||
| private class PartitionWriterStream extends OutputStream { | ||
| private int count = 0; | ||
| private boolean isClosed = false; | ||
|
|
||
|
|
@@ -199,7 +202,6 @@ public void write(int b) throws IOException { | |
| if (isClosed) { | ||
| throw new IllegalStateException("Attempting to write to a closed block output stream."); | ||
| } | ||
| successfulWrite = true; | ||
| outputBufferedFileStream.write(b); | ||
| count++; | ||
| } | ||
|
|
@@ -216,7 +218,7 @@ public void flush() throws IOException { | |
| } | ||
| } | ||
|
|
||
| private class DefaultShuffleBlockByteChannel implements WritableByteChannel { | ||
| private class PartitionWriterChannel implements WritableByteChannel { | ||
|
|
||
| private int count = 0; | ||
| private boolean isClosed = false; | ||
|
|
@@ -230,7 +232,6 @@ public int write(ByteBuffer src) throws IOException { | |
| if (isClosed) { | ||
| throw new IllegalStateException("Attempting to write to a closed block byte channel."); | ||
| } | ||
| successfulWrite = true; | ||
| int written = outputFileChannel.write(src); | ||
| count += written; | ||
| return written; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.