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

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

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?

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