Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6638#discussion_r34765496
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/ScriptTransformation.scala
 ---
    @@ -66,55 +67,23 @@ case class ScriptTransformation(
           val inputStream = proc.getInputStream
           val outputStream = proc.getOutputStream
           val errorStream = proc.getErrorStream
    -      val reader = new BufferedReader(new InputStreamReader(inputStream))
    -
           val (outputSerde, outputSoi) = ioschema.initOutputSerDe(output)
     
           val iterator: Iterator[InternalRow] = new Iterator[InternalRow] with 
HiveInspectors {
    -        var cacheRow: InternalRow = null
    -        var curLine: String = null
    -        var eof: Boolean = false
    -
    +        val scriptOutputStream = new DataInputStream(inputStream)
    +        var scriptOutputWritable: Writable = null
    +        // This method blocks until the inputdata availble or reach EOF
             override def hasNext: Boolean = {
    -          if (outputSerde == null) {
    -            if (curLine == null) {
    -              curLine = reader.readLine()
    -              curLine != null
    -            } else {
    +          if (scriptOutputWritable == null) {
    +            scriptOutputWritable = 
outputSerde.getSerializedClass().newInstance
    --- End diff --
    
    I mean we'd better to reuse the `scriptOutputWritable`.


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