10110346 commented on a change in pull request #23296: [mllib]MergeAggregate 
serialize and deserialize function use Bytebuffer to optimize
URL: https://github.com/apache/spark/pull/23296#discussion_r240918718
 
 

 ##########
 File path: mllib/src/main/scala/org/apache/spark/ml/stat/Summarizer.scala
 ##########
 @@ -609,16 +611,16 @@ private[ml] object SummaryBuilderImpl extends Logging {
       = new SummarizerBuffer(requestedMetrics, requestedComputeMetrics)
 
     override def serialize(state: SummarizerBuffer): Array[Byte] = {
-      // TODO: Use ByteBuffer to optimize
-      val bos = new ByteArrayOutputStream()
+      // Use ByteBuffer
+      val bos = new ByteBufferOutputStream()
       val oos = new ObjectOutputStream(bos)
       oos.writeObject(state)
       bos.toByteArray
 
 Review comment:
   `bos.toByteArray` has  a data copy.
   `bos.toByteArray => bos.toByteBuffer.array`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to