spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yhuai <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-11017] [SQL] Support ImperativeAggregat...
Date Fri, 09 Oct 2015 19:55:53 GMT
Github user yhuai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9038#discussion_r41671522
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/TungstenAggregationIterator.scala
---
    @@ -288,17 +419,33 @@ class TungstenAggregationIterator(
             val joinedRow = new JoinedRow()
             val evalExpressions = allAggregateFunctions.map {
               case ae: DeclarativeAggregate => ae.evaluateExpression
    -          // case agg: AggregateFunction2 => Literal.create(null, agg.dataType)
    +          case agg: AggregateFunction2 => NoOp
             }
    -        val expressionAggEvalProjection = UnsafeProjection.create(evalExpressions, bufferAttributes)
    +        val expressionAggEvalProjection = newMutableProjection(evalExpressions, bufferAttributes)()
             // These are the attributes of the row produced by `expressionAggEvalProjection`
             val aggregateResultSchema = nonCompleteAggregateAttributes ++ completeAggregateAttributes
    +        // TODO: Use unsafe row.
    +        val aggregateResult = new SpecificMutableRow(aggregateResultSchema.map(_.dataType))
    +        expressionAggEvalProjection.target(aggregateResult)
             val resultProjection =
               UnsafeProjection.create(resultExpressions, groupingAttributes ++ aggregateResultSchema)
     
    +        val allImperativeAggregateFunctions: Array[ImperativeAggregate] =
    +          allImperativeAggregateFunctionPositions
    +            .map(allAggregateFunctions)
    +            .map(_.asInstanceOf[ImperativeAggregate])
    +
             (currentGroupingKey: UnsafeRow, currentBuffer: UnsafeRow) => {
               // Generate results for all expression-based aggregate functions.
    -          val aggregateResult = expressionAggEvalProjection.apply(currentBuffer)
    +          expressionAggEvalProjection(currentBuffer)
    +          // Generate results for all imperative aggregate functions.
    +          var i = 0
    +          while (i < allImperativeAggregateFunctions.length) {
    +            aggregateResult.update(
    --- End diff --
    
    Will https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/udaf.scala#L99-L202
help?


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


Mime
View raw message