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-27336] Avoid merging when there is only one record #104

Merged
merged 2 commits into from Jul 4, 2022

Conversation

SteNicholas
Copy link
Member

If there is just one record, still use MergeFunction to merge. This is not necessary, just output directly.

The brief change log

  • Updates the merge in the SortBufferMemTable and SortMergeReader to output directly if there is only one record, and use MergeFunction to merge in the case of multiple records.

Copy link
Contributor

@tsreaper tsreaper left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! Overall this is a good optimization but I have some doubts on the implementation.

I think we should introduce an abstract merger class to deal with this optimization instead of implementing it in the caller, otherwise we'll have to repeat the implementation every time we use a merger.

Also there is no tests verifying this change. Please add some tests.

Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

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

Thanks @SteNicholas for the contribution. Left two comments.

Currently we have to change the func wherever we use it. To avoid this, can we create a MergeFunctionHelper (maybe there is a better name) class which is responsible for avoiding calling MergeFunction when there is only one record in it.

We can also add tests against this class.

@SteNicholas
Copy link
Member Author

SteNicholas commented Apr 28, 2022

@JingsongLi @tsreaper, IMO, the current tests could cover the execution logic branch, hence I have not added some extra tests to verify. WDYT?

@JingsongLi
Copy link
Contributor

@JingsongLi @tsreaper, IMO, the current tests could cover the execution logic branch, hence I have not added some extra tests to verify. WDYT?

At least, you can add some unit tests on the new Helper.

@LadyForest
Copy link
Contributor

Hi @SteNicholas, are you still following up?

@SteNicholas
Copy link
Member Author

SteNicholas commented Jun 30, 2022

@JingsongLi, I have addressed above comments and the failure of the UTCase/ITCase isn't related to this change.
PTAL.

Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

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

Thanks for the update! Looks good to me!

@JingsongLi JingsongLi merged commit badc4cf into apache:master Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants