You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by davies <gi...@git.apache.org> on 2015/09/03 20:01:49 UTC

[GitHub] spark pull request: [SPARK-10065][SQL] avoid the extra copy when g...

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

    https://github.com/apache/spark/pull/8496#discussion_r38676358
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateUnsafeProjection.scala ---
    @@ -393,22 +362,22 @@ object GenerateUnsafeProjection extends CodeGenerator[Seq[Expression], UnsafePro
         case t: StructType =>
           val output = ctx.freshName("convertedStruct")
           val outputIsNull = ctx.freshName("isNull")
    -      val tmp = ctx.freshName("tmp")
           val fieldTypes = t.fields.map(_.dataType)
           val fieldEvals = fieldTypes.zipWithIndex.map { case (dt, i) =>
    -        val getFieldCode = ctx.getValue(tmp, dt, i.toString)
    -        val fieldIsNull = s"$tmp.isNullAt($i)"
    -        GeneratedExpressionCode("", fieldIsNull, getFieldCode)
    +        val fieldName = ctx.freshName("fieldName")
    +        val code = s"${ctx.javaType(dt)} $fieldName = " +
    +          s"${ctx.getValue(input.primitive, dt, i.toString)};"
    +        val isNull = s"${input.primitive}.isNullAt($i)"
    +        GeneratedExpressionCode(code, isNull, fieldName)
           }
    -      val converter = createCodeForStruct(ctx, tmp, fieldEvals, fieldTypes)
    +      val converter = createCodeForStruct(ctx, input.primitive, fieldEvals, fieldTypes)
           val code = s"""
             ${input.code}
              UnsafeRow $output = null;
              final boolean $outputIsNull = ${input.isNull};
              if (!$outputIsNull) {
    -           final InternalRow $tmp = ${input.primitive};
    --- End diff --
    
    Why remove this? I think it's good to have that, `input.primitive` could be an expression


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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