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

    https://github.com/apache/spark/pull/993#discussion_r15332107
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateProjection.scala
 ---
    @@ -0,0 +1,218 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions.codegen
    +
    +import org.apache.spark.sql.catalyst.expressions._
    +import org.apache.spark.sql.catalyst.types._
    +
    +
    +/**
    + * Generates bytecode that produces a new [[Row]] object based on a fixed 
set of input
    + * [[Expression Expressions]] and a given input [[Row]].  The returned 
[[Row]] object is custom
    + * generated based on the output types of the [[Expression]] to avoid 
boxing of primitive values.
    + */
    +object GenerateProjection extends CodeGenerator[Seq[Expression], 
Projection] {
    +  import scala.reflect.runtime.{universe => ru}
    +  import scala.reflect.runtime.universe._
    +
    +  protected def canonicalize(in: Seq[Expression]): Seq[Expression] =
    +    in.map(ExpressionCanonicalizer(_))
    +
    +  protected def bind(in: Seq[Expression], inputSchema: Seq[Attribute]): 
Seq[Expression] =
    +    in.map(BindReferences.bindReference(_, inputSchema))
    +
    +  // Make Mutablility optional...
    +  protected def create(expressions: Seq[Expression]): Projection = {
    +    val tupleLength = ru.Literal(Constant(expressions.length))
    +    val lengthDef = q"final val length = $tupleLength"
    +
    +    /* TODO: Configurable...
    +    val nullFunctions =
    +      q"""
    +        private final val nullSet = new 
org.apache.spark.util.collection.BitSet(length)
    +        final def setNullAt(i: Int) = nullSet.set(i)
    +        final def isNullAt(i: Int) = nullSet.get(i)
    +      """
    +     */
    +
    +    val nullFunctions =
    +      q"""
    +        private[this] var nullBits = new 
Array[Boolean](${expressions.size})
    +        final def setNullAt(i: Int) = { nullBits(i) = true }
    +        final def isNullAt(i: Int) = nullBits(i)
    +      """.children
    +
    +    val tupleElements = expressions.zipWithIndex.flatMap {
    +      case (e, i) =>
    +        val elementName = newTermName(s"c$i")
    +        val evaluatedExpression = expressionEvaluator(e)
    --- End diff --
    
    where is expressionEvaluator defined?


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

Reply via email to