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

    https://github.com/apache/spark/pull/16857#discussion_r101594563
  
    --- Diff: 
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaSource.scala
 ---
    @@ -97,16 +100,29 @@ private[kafka010] class KafkaSource(
         val metadataLog =
           new HDFSMetadataLog[KafkaSourceOffset](sqlContext.sparkSession, 
metadataPath) {
             override def serialize(metadata: KafkaSourceOffset, out: 
OutputStream): Unit = {
    -          val bytes = metadata.json.getBytes(StandardCharsets.UTF_8)
    -          out.write(bytes.length)
    -          out.write(bytes)
    +          out.write(0) // A zero byte is written to support Spark 2.1.0 
(SPARK-19517)
    +          val writer = new BufferedWriter(new OutputStreamWriter(out, 
StandardCharsets.UTF_8))
    +          writer.write(s"$VERSION\n${metadata.json}")
    --- End diff --
    
    nit: I prefer to use multiple `write`s to avoid creating the temp string.


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