Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7392#discussion_r34541583
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateProjection.scala
 ---
    @@ -151,85 +151,96 @@ object GenerateProjection extends 
CodeGenerator[Seq[Expression], Projection] {
             s"""if (!nullBits[$i]) arr[$i] = c$i;"""
         }.mkString("\n      ")
     
    +    val mutableStates = ctx.mutableStates.map {
    +      case (jt, name, _) => s"private $jt $name;"
    +    }.mkString("\n      ")
    +
    +    val initStates = ctx.mutableStates.zipWithIndex.map {
    +      case ((jt, name, _), index) => s"$name = (${ctx.boxedType(jt)}) 
states[$index];"
    +    }.mkString("\n        ")
    +
         val code = s"""
    -    public SpecificProjection generate($exprType[] expr) {
    -      return new SpecificProjection(expr);
    +    public SpecificProjection generate($exprType[] expr, Object[] states) {
    +      return new SpecificProjection(expr, states);
         }
     
         class SpecificProjection extends ${classOf[BaseProject].getName} {
           private $exprType[] expressions = null;
    +      $mutableStates
     
    -      public SpecificProjection($exprType[] expr) {
    +      public SpecificProjection($exprType[] expr, Object[] states) {
             expressions = expr;
    +        $initStates
           }
     
           @Override
           public Object apply(Object r) {
    -        return new SpecificRow(expressions, (InternalRow) r);
    +        return new SpecificRow((InternalRow) r);
           }
    -    }
     
    -    final class SpecificRow extends ${classOf[MutableRow].getName} {
    +      final class SpecificRow extends ${classOf[MutableRow].getName} {
    --- End diff --
    
    I made `SpecificRow` a inner class of `SpecificProjection` here, so that we 
can access these mutable states easily.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to