Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15437#discussion_r83096847
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/CompactibleFileStreamLog.scala
 ---
    @@ -93,20 +95,26 @@ abstract class CompactibleFileStreamLog[T: ClassTag](
         }
       }
     
    -  override def serialize(logData: Array[T]): Array[Byte] = {
    -    (metadataLogVersion +: 
logData.map(serializeData)).mkString("\n").getBytes(UTF_8)
    +  override def serialize(logData: Array[T], out: OutputStream): Unit = {
    +    // called inside a try-finally where the underlying stream is closed 
in the caller
    +    out.write(metadataLogVersion.getBytes(UTF_8))
    +    logData.foreach { data =>
    +      out.write('\n')
    +      out.write(serializeData(data).getBytes(UTF_8))
    +    }
    +    out.flush()
       }
     
    -  override def deserialize(bytes: Array[Byte]): Array[T] = {
    -    val lines = new String(bytes, UTF_8).split("\n")
    -    if (lines.length == 0) {
    +  override def deserialize(in: InputStream): Array[T] = {
    +    val lines = IOUtils.lineIterator(in, UTF_8).asScala
    --- End diff --
    
    nit: why not use `Source.getLines` since this is Scala.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to