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

Prevent unnecessary optimisation of already optimised Range Index expressions #4882

Merged
merged 11 commits into from
Sep 2, 2024

Conversation

marmoure
Copy link
Collaborator

@marmoure marmoure commented Apr 24, 2023

Closes #3624

This PR prevents optimizing an already optimized expression.

It reverts the previous fix in PR #3625 as that PR causes eXist-db to do more work that necessary. This PR takes a simpler approach that requires less processing and less creation of objects by eXist-db (and therefore is faster and more memory efficient).


This open source contribution to the exist project was commissioned by the Office of the Historian, U.S. Department of State, https://history.state.gov/.

@adamretter adamretter force-pushed the fix/3624 branch 2 times, most recently from 2d1f6c4 to 77231a9 Compare July 16, 2023 20:30
@eXist-db eXist-db deleted a comment from marmoure Jul 16, 2023
@adamretter adamretter marked this pull request as ready for review July 16, 2023 20:33
@adamretter adamretter changed the title WIP [bugfix] check before optimizing innerExpr Prevent unnecessary optimisation of already optimised Range Index expressions Jul 16, 2023
@adamretter adamretter added this to the eXist-7.0.0 milestone Jul 16, 2023
@adamretter adamretter added bug issue confirmed as bug enhancement new features, suggestions, etc. labels Jul 16, 2023
@sonarcloud
Copy link

sonarcloud bot commented Jul 18, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

72.5% 72.5% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Comment on lines +200 to 203
if (expression instanceof final InternalFunctionCall fcall) {
expression = fcall.getFunction();
}
this.fallback = expression;
Copy link
Member

Choose a reason for hiding this comment

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

@marmoure you may fix this Codacy issue by using a if /else block:

if (expression instanceof final InternalFunctionCall fcall) {
    this.fallback  = fcall.getFunction();
} else {
    this.fallback = expression;
}  

Copy link
Member

Choose a reason for hiding this comment

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

Whilst the end result is the same. I am not sure this is the same intention, it was meant to be clear that we are replacing the expression. @reinhapa How strongly do you feel about this?

Copy link
Member

Choose a reason for hiding this comment

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

Well I would like to somehow bring the total qualtiy issues down when they pop up as I think we should try to avoid new issues if possible...

Comment on lines +200 to 203
if (expression instanceof final InternalFunctionCall fcall) {
expression = fcall.getFunction();
}
this.fallback = expression;
Copy link
Member

Choose a reason for hiding this comment

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

Whilst the end result is the same. I am not sure this is the same intention, it was meant to be clear that we are replacing the expression. @reinhapa How strongly do you feel about this?

@adamretter
Copy link
Member

@dizzzz @reinhapa this is now rebased - are you happy with it?

Copy link
Member

@adamretter adamretter left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks

@reinhapa reinhapa merged commit 4909edb into eXist-db:develop Sep 2, 2024
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issue confirmed as bug enhancement new features, suggestions, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] NPE at org.exist.xquery.modules.range.RangeQueryRewriter.rewriteLocationStep
4 participants