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
Conversation
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 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.
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 @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.
...store-core/src/main/java/org/apache/flink/table/store/file/mergetree/SortBufferMemTable.java
Outdated
Show resolved
Hide resolved
...store-core/src/main/java/org/apache/flink/table/store/file/mergetree/SortBufferMemTable.java
Outdated
Show resolved
Hide resolved
@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 |
Hi @SteNicholas, are you still following up? |
@JingsongLi, I have addressed above comments and the failure of the UTCase/ITCase isn't related to this change. |
...e/src/main/java/org/apache/flink/table/store/file/mergetree/compact/MergeFunctionHelper.java
Outdated
Show resolved
Hide resolved
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 update! Looks good to me!
If there is just one record, still use
MergeFunction
to merge. This is not necessary, just output directly.The brief change log
SortBufferMemTable
andSortMergeReader
to output directly if there is only one record, and useMergeFunction
to merge in the case of multiple records.