-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
HHH-18754 Improve HQLParser's error listener usage #9140
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thanks for your pull request! This pull request appears to follow the contribution rules. › This message was automatically generated. |
NathanQingyangXu
changed the title
HHH-18754 improve HQLParser's error listener usage in StandardHqlTran…
HHH-18754 improve HQLParser's error listener usage
Oct 23, 2024
NathanQingyangXu
changed the title
HHH-18754 improve HQLParser's error listener usage
HHH-18754 Improve HQLParser's error listener usage
Oct 23, 2024
NathanQingyangXu
force-pushed
the
HHH-18754
branch
from
October 26, 2024 22:58
3f8893c
to
7a66c0a
Compare
NathanQingyangXu
force-pushed
the
HHH-18754
branch
from
October 30, 2024 22:43
7a66c0a
to
c1dff2b
Compare
gavinking
approved these changes
Nov 1, 2024
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.
LGTM
I'm curious, have you actually verified that? |
I verified that locally for sure, but the perf improvement is minor.
…On Fri, Nov 1, 2024, 2:28 p.m. Steve Ebersole ***@***.***> wrote:
needless to say, it would improve perf by avoiding unnecessary processing
I'm curious, have you actually verified that?
—
Reply to this email directly, view it on GitHub
<#9140 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB6UYAXRRRC2WL2QTO7WEMDZ6PB4TAVCNFSM6AAAAABQN4KDW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJSGM3TGOBXGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
But my verification is restrictive only to SLL step. Later on I found LL
step would be simply skipped totally for we throw exception in the error
listener, which ends up with much bigger problem.
Next step is to avoid the listen creation in the first place for hql is
accessible from the error listener parameter, as the ANTLR book
demonstrates.
On Fri, Nov 1, 2024, 10:41 p.m. Nathan Xu ***@***.***>
wrote:
… I verified that locally for sure, but the perf improvement is minor.
On Fri, Nov 1, 2024, 2:28 p.m. Steve Ebersole ***@***.***>
wrote:
> needless to say, it would improve perf by avoiding unnecessary processing
>
> I'm curious, have you actually verified that?
>
> —
> Reply to this email directly, view it on GitHub
> <#9140 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AB6UYAXRRRC2WL2QTO7WEMDZ6PB4TAVCNFSM6AAAAABQN4KDW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJSGM3TGOBXGE>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://hibernate.atlassian.net/browse/HHH-18754
Below is the code pattern for HQL parsing (at
org.hibernate.query.hql.internal.StandardHqlTranslator
):firstly it is confusing to add the error listener BEFORE setting mode to SLL, then afterwards add it again (empty the listnerers first), as if the error listener will be used during the SLL setting statement (it won’t for it is simply a variable setting) as below:
but this is minor.
So I guess the two-step approach might be from this article Improving the performance of an ANTLR parser - Strumenta , but there is no reason to set error listener to both steps for the following reasons:
if SLL failed and the error listener takes effect, there might be possibility that the second LL step succeeds, then user got confused by the error message;
if SLL failed and then LL failed as well, user will be notified twice. LL step won’t skip error listener notification and I think in this scenario, LL step’s error listener message suffices.
Most seriously, given we throw SyntaxError exception in the syntaxError() method in the error listener, the LL step would be totally skipped!!
All in all, it seems there is no reason to use error listener for the first SLL step. What really matters might be the final step. So moving the error listener creation and setting logic into the LL step makes more sense (needless to say, it would improve perf by avoiding unnecessary processing) as below: