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

    https://github.com/apache/spark/pull/11636#discussion_r56883452
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/ExistingRDD.scala ---
    @@ -217,19 +241,29 @@ private[sql] case class DataSourceScan(
         // TODO: The abstractions between this class and SqlNewHadoopRDD makes 
it difficult to know
         // here which path to use. Fix this.
     
    -    ctx.INPUT_ROW = row
    +    // These assignments avoids accesses to instance variables in a 
while-loop
    +    // Since they are loop invariant variables (LIVs), host them outside 
the while-loop
    +    val colLocalVars = output.zipWithIndex.map(x => ctx.freshName("col" + 
x._2))
    +    val columnLIVAssigns = (colLocalVars zip colVars).map { case 
(localName, name) =>
    +      s"$columnVectorClz $localName = $name;" }
    +
         ctx.currentVars = null
    -    val columns1 = exprs.map(_.gen(ctx))
    +    val columns1 = (output zip colLocalVars).map { case (attr, colVar) =>
    +      genCodeColumnVector(ctx, colVar, rowidx, attr.dataType, 
attr.nullable) }
         val scanBatches = ctx.freshName("processBatches")
         ctx.addNewFunction(scanBatches,
           s"""
           | private void $scanBatches() throws java.io.IOException {
           |  while (true) {
           |     int numRows = $batch.numRows();
    -      |     if ($idx == 0) $numOutputRows.add(numRows);
    +      |     if ($idx == 0) {
    +      |       ${columnAssigns.mkString("", "\n", "\n")}
    +      |       $numOutputRows.add(numRows);
    +      |     }
           |
    +      |     ${columnLIVAssigns.mkString("", "\n", "\n")}
    --- End diff --
    
    For now, I will not use this. In the future, I may revisit this scala 
replacement regarding all of possible variables in another PR.


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