mridulm commented on a change in pull request #33721:
URL: https://github.com/apache/spark/pull/33721#discussion_r688173524



##########
File path: core/src/main/scala/org/apache/spark/MapOutputTracker.scala
##########
@@ -1335,22 +1334,23 @@ private[spark] object MapOutputTracker extends Logging {
     } {
       objOut.close()
     }
-    val arr = out.toByteArray
-    if (arr.length >= minBroadcastSize) {
+    // create a nested Array so that it can handle over 2GB serialized data
+    val arr = out.toChunkedByteBuffer.getChunks().map(_.array())
+    val arrSize = out.size
+    if (arrSize >= minBroadcastSize) {
       // Use broadcast instead.
       // Important arr(0) is the tag == DIRECT, ignore that while 
deserializing !
       val bcast = broadcastManager.newBroadcast(arr, isLocal)
-      // toByteArray creates copy, so we can reuse out
-      out.reset()
+      val out = new ChunkedByteBufferOutputStream(chunkSize, 
ByteBuffer.allocate _)

Review comment:
       Here we are serializing the broadcast - `ApacheByteArrayOutputStream` is 
sufficient.

##########
File path: core/src/main/scala/org/apache/spark/MapOutputTracker.scala
##########
@@ -1318,12 +1319,10 @@ private[spark] object MapOutputTracker extends Logging {
       broadcastManager: BroadcastManager,
       isLocal: Boolean,
       minBroadcastSize: Int,
-      conf: SparkConf): (Array[Byte], Broadcast[Array[Byte]]) = {
-    // Using `org.apache.commons.io.output.ByteArrayOutputStream` instead of 
the standard one
-    // This implementation doesn't reallocate the whole memory block but 
allocates
-    // additional buffers. This way no buffers need to be garbage collected and
-    // the contents don't have to be copied to the new buffer.
-    val out = new ApacheByteArrayOutputStream()
+      conf: SparkConf): (Array[Array[Byte]], Broadcast[Array[Array[Byte]]]) = {

Review comment:
       Only the broadcast variable needs to change to `Array[Array[Byte]]` - as 
we enforce `minBroadcastSize`.
   




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to