flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-6242) codeGen DataSet Goupingwindow Aggregates
Date Tue, 18 Apr 2017 20:21:42 GMT

    [ https://issues.apache.org/jira/browse/FLINK-6242?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15973412#comment-15973412
] 

ASF GitHub Bot commented on FLINK-6242:
---------------------------------------

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

    https://github.com/apache/flink/pull/3735#discussion_r111986866
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala
---
    @@ -263,33 +263,56 @@ class CodeGenerator(
          aggFields: Array[Array[Int]],
          aggMapping: Array[Int],
          fwdMapping: Array[(Int, Int)],
    -     outputArity: Int)
    +     outputArity: Int,
    +     groupingKeys: Array[Int])
       : GeneratedAggregationsFunction = {
     
         def genSetAggregationResults(
           accTypes: Array[String],
           aggs: Array[String],
           aggMapping: Array[Int]): String = {
     
    -      val sig: String =
    +      val sigHelper: String =
             j"""
    -            |  public void setAggregationResults(
    -            |    org.apache.flink.types.Row accs,
    -            |    org.apache.flink.types.Row output)""".stripMargin
    +           |  private final void setAggregationResultsHelper(
    +           |    org.apache.flink.types.Row accs,
    +           |    org.apache.flink.types.Row output,
    +           |    java.lang.Integer offset)""".stripMargin
     
    -      val setAggs: String = {
    +      val setAggsHelper: String = {
             for (i <- aggs.indices) yield
               j"""
                  |    org.apache.flink.table.functions.AggregateFunction baseClass$i =
                  |      (org.apache.flink.table.functions.AggregateFunction) ${aggs(i)};
                  |
                  |    output.setField(
    -             |      ${aggMapping(i)},
    +             |      ${aggMapping(i)} + offset,
                  |      baseClass$i.getValue((${accTypes(i)}) accs.getField($i)));""".stripMargin
           }.mkString("\n")
     
    -      j"""$sig {
    -         |$setAggs
    +      val setAggregationResults: String =
    +        j"""
    +           |  public void setAggregationResults(
    +           |    org.apache.flink.types.Row accs,
    +           |    org.apache.flink.types.Row output) {
    +           |    setAggregationResultsHelper(accs, output, 0);
    --- End diff --
    
    Code generated methods should be as "flat" as possible. Calling other helper methods adds
overhead compared to inlining the code.


> codeGen DataSet Goupingwindow Aggregates
> ----------------------------------------
>
>                 Key: FLINK-6242
>                 URL: https://issues.apache.org/jira/browse/FLINK-6242
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table API & SQL
>            Reporter: Shaoxuan Wang
>            Assignee: Shaoxuan Wang
>




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message