Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-7194] [table] Add methods for type hints to UDAGG interface. #4379

Closed
wants to merge 3 commits into from

Conversation

fhueske
Copy link
Contributor

@fhueske fhueske commented Jul 20, 2017

  • General

    • The pull request references the related JIRA issue ("[FLINK-XXX] Jira title text")
    • The pull request addresses only one issue
    • Each commit in the PR has a meaningful commit message (including the JIRA id)
  • Documentation

    • Documentation for UDAGGs will be provided by FLINK-6751
  • JavaDoc for public methods has been added

  • Tests & Build

    • Functionality added by the pull request is covered by tests
    • mvn clean verify has been executed successfully locally or a Travis build has passed

Copy link
Member

@sunjincheng121 sunjincheng121 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fhueske Thanks for the PR. I like the changes. I only left a couple of suggestions.

Thanks, Jincheng

*/
def requiresOver: Boolean = false

/**
* Returns the TypeInformation for the result of the AggregateFunction.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeInformation for the result -> TypeInformation of the result

def getResultType: TypeInformation[T] = null

/**
* Returns the TypeInformation for the accumulator of the AggregateFunction.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns the TypeInformation for -> Returns of TypeInformation for

@@ -191,10 +191,10 @@ class DecimalSumWithRetractAggFunction
acc.f1 = 0L
}

def getAccumulatorType(): TypeInformation[_] = {
override def getAccumulatorType(): TypeInformation[DecimalSumWithRetractAccumulator] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getAccumulatorType()->getAccumulatorType

@@ -17,6 +17,8 @@
*/
package org.apache.flink.table.functions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to remove the useless java doc, something like:

  1. line 35 - getAccumulatorType.
  2. line 102 to line 112 def getResultType: TypeInformation[_]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks

@@ -80,11 +80,11 @@ abstract class IntegralAvgAggFunction[T] extends AggregateFunction[T, IntegralAv
acc.f1 = 0L
}

def getAccumulatorType: TypeInformation[_] = {
override def getAccumulatorType: TypeInformation[IntegralAvgAccumulator] = {
new TupleTypeInfo(
new IntegralAvgAccumulator().getClass,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about classOf[IntegralAvgAccumulator], Although classOf[T] is equivalent to the class literal T.class in Java. but I think it is more concise.What do you think?

s"You can override AggregateFunction.getResultType() to specify the type.",
ite)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion(I am not sure the suggestion is better or not):
Extract common code for getResultTypeOfAggregateFunction and getAccumulatorTypeOfAggregateFunction. Something like following:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the TypeExtractor part into a separate method

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

@fhueske
Copy link
Contributor Author

fhueske commented Jul 21, 2017

Thanks for the review @sunjincheng121.
I updated the PR.

@sunjincheng121
Copy link
Member

sunjincheng121 commented Jul 21, 2017

Hi @fhueske Thanks for the update. The PR. looks good to me. -:)

+1 to merge.

@wuchong
Copy link
Member

wuchong commented Jul 21, 2017

Loos good to me. +1 to merge

@sunjincheng121
Copy link
Member

Merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants