@@ -19,19 +19,18 @@ import java.nio.ByteBuffer
19
19
import java .nio .channels .{Channels , WritableByteChannel }
20
20
import java .util .Optional
21
21
22
- /**
23
- * Implements the ShuffleMapOutputWriter interface. It stores the shuffle output in one
24
- * shuffle block.
25
- *
26
- * This file is based on Spark "LocalDiskShuffleMapOutputWriter.java".
27
- */
22
+ /** Implements the ShuffleMapOutputWriter interface. It stores the shuffle output in one shuffle block.
23
+ *
24
+ * This file is based on Spark "LocalDiskShuffleMapOutputWriter.java".
25
+ */
28
26
29
27
class S3ShuffleMapOutputWriter (
30
- conf : SparkConf ,
31
- shuffleId : Int ,
32
- mapId : Long ,
33
- numPartitions : Int ,
34
- ) extends ShuffleMapOutputWriter with Logging {
28
+ conf : SparkConf ,
29
+ shuffleId : Int ,
30
+ mapId : Long ,
31
+ numPartitions : Int
32
+ ) extends ShuffleMapOutputWriter
33
+ with Logging {
35
34
val dispatcher = S3ShuffleDispatcher .get
36
35
37
36
/* Target block for writing */
@@ -44,7 +43,8 @@ class S3ShuffleMapOutputWriter(
44
43
def initStream (): Unit = {
45
44
if (stream == null ) {
46
45
stream = dispatcher.createBlock(shuffleBlock)
47
- bufferedStream = new S3MeasureOutputStream (new BufferedOutputStream (stream, dispatcher.bufferSize), shuffleBlock.name)
46
+ bufferedStream =
47
+ new S3MeasureOutputStream (new BufferedOutputStream (stream, dispatcher.bufferSize), shuffleBlock.name)
48
48
}
49
49
}
50
50
@@ -59,10 +59,11 @@ class S3ShuffleMapOutputWriter(
59
59
private var totalBytesWritten : Long = 0
60
60
private var lastPartitionWriterId : Int = - 1
61
61
62
- /**
63
- * @param reducePartitionId Monotonically increasing, as per contract in ShuffleMapOutputWriter.
64
- * @return An instance of the ShufflePartitionWriter exposing the single output stream.
65
- */
62
+ /** @param reducePartitionId
63
+ * Monotonically increasing, as per contract in ShuffleMapOutputWriter.
64
+ * @return
65
+ * An instance of the ShufflePartitionWriter exposing the single output stream.
66
+ */
66
67
override def getPartitionWriter (reducePartitionId : Int ): ShufflePartitionWriter = {
67
68
if (reducePartitionId <= lastPartitionWriterId) {
68
69
throw new RuntimeException (" Precondition: Expect a monotonically increasing reducePartitionId." )
@@ -81,19 +82,21 @@ class S3ShuffleMapOutputWriter(
81
82
new S3ShufflePartitionWriter (reducePartitionId)
82
83
}
83
84
84
- /**
85
- * Close all writers and the shuffle block.
86
- *
87
- * @param checksums Ignored.
88
- * @return
89
- */
85
+ /** Close all writers and the shuffle block.
86
+ *
87
+ * @param checksums
88
+ * Ignored.
89
+ * @return
90
+ */
90
91
override def commitAllPartitions (checksums : Array [Long ]): MapOutputCommitMessage = {
91
92
if (bufferedStream != null ) {
92
93
bufferedStream.flush()
93
94
}
94
95
if (stream != null ) {
95
96
if (stream.getPos != totalBytesWritten) {
96
- throw new RuntimeException (f " S3ShuffleMapOutputWriter: Unexpected output length ${stream.getPos}, expected: ${totalBytesWritten}. " )
97
+ throw new RuntimeException (
98
+ f " S3ShuffleMapOutputWriter: Unexpected output length ${stream.getPos}, expected: ${totalBytesWritten}. "
99
+ )
97
100
}
98
101
}
99
102
if (bufferedStreamAsChannel != null ) {
@@ -198,8 +201,7 @@ class S3ShuffleMapOutputWriter(
198
201
}
199
202
}
200
203
201
- private class S3ShufflePartitionWriterChannel (reduceId : Int )
202
- extends WritableByteChannelWrapper {
204
+ private class S3ShufflePartitionWriterChannel (reduceId : Int ) extends WritableByteChannelWrapper {
203
205
private val partChannel = new S3PartitionWritableByteChannel (bufferedStreamAsChannel)
204
206
205
207
override def channel (): WritableByteChannel = {
@@ -216,8 +218,7 @@ class S3ShuffleMapOutputWriter(
216
218
}
217
219
}
218
220
219
- private class S3PartitionWritableByteChannel (channel : WritableByteChannel )
220
- extends WritableByteChannel {
221
+ private class S3PartitionWritableByteChannel (channel : WritableByteChannel ) extends WritableByteChannel {
221
222
222
223
private var count : Long = 0
223
224
@@ -229,8 +230,7 @@ class S3ShuffleMapOutputWriter(
229
230
channel.isOpen()
230
231
}
231
232
232
- override def close (): Unit = {
233
- }
233
+ override def close (): Unit = {}
234
234
235
235
override def write (x : ByteBuffer ): Int = {
236
236
var c = 0
0 commit comments