-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-19896][table-blink] Improve first-n-row fetching in the Rank o… #13921
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
Conversation
|
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit 5b90fd3 (Sat Aug 28 12:14:32 UTC 2021) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. DetailsThe Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
|
@wuchong @godfreyhe would you mind take a look? |
|
Hi @tragicjun, can you rebase latest master? |
Hi @JingsongLi rebase latest master done, please take a look. |
JingsongLi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the rebasing. @tragicjun Can you create a ITCase or point out which ITCase you want to solve?
| */ | ||
| public class AppendOnlyFirstNFunction extends AbstractTopNFunction { | ||
|
|
||
| private static final long serialVersionUID = -889227691088906246L; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serialVersionUID should be 1L at first, From the Flink code style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serialVersionUID is at the 2nd in all other classes, thus in consistent with them.
| cacheSize); | ||
| if (sortFields.length == 1 | ||
| && inputType.getChildren().get(sortFields[0]).getTypeRoot() | ||
| == LogicalTypeRoot.TIMESTAMP_WITHOUT_TIME_ZONE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just TIMESTAMP_WITHOUT_TIME_ZONE? I don't see any proc-time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, forgot to push the latest commit.
Thanks for reviewing. I have added an ITCase as RankJsonPlanITCase.testFirstN(). Please let me know if any issues. |
| boolean isAppendOnlyFirstN = false; | ||
| if (sortFields.length == 1) { | ||
| LogicalType sortKeyType = inputType.getChildren().get(sortFields[0]); | ||
| if (sortKeyType instanceof LocalZonedTimestampType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeCheckUtils.isProcTime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great, thx
|
@tragicjun still some compile failure. |
sorry, some format violation. Project build passed on my local, please review. |
JingsongLi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tragicjun for the update.
Looks good to me, merging...
What is the purpose of the change
Fetching first N rows is a special case of TopN, which currently is supported by the Rank operator. However, the full-fledged TopN implementation is heavyweight in that it involves sort key comparison and raw row buffering. This leads to large state and memory buffer that is not needed for the first-n-row case. This PR introduces a lightweight variant of TopN function to handle it more efficiently.
Brief change log
AppendOnlyFirstNFunctionas a variant of AppendOnlyTopNFunctionStreamExecRankto instantiateAppendOnlyFirstNFuncitonwhen the first-n-row case is determinedVerifying this change
This change added tests and can be verified as follows:
AppendOnlyFirstNFunctionTestDoes this pull request potentially affect one of the following parts:
@Public(Evolving): ( no)Documentation