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

[refactor] Restructure RangeIndexAttributeCondition #5259

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

Conversation

line-o
Copy link
Member

@line-o line-o commented Mar 26, 2024

Description:

These private properties of RangeIndexAttributeCondition

  • String value
  • boolean caseSensitive
  • boolean numericComparison
  • Double numericValue
  • String lowercaseValue
  • Pattern pattern

were replaced by

  • boolean commutative
  • boolean commutativeNegate
  • Predicate indexPredicate
  • Predicate queryPredicate

indexPredicate and queryPredicate are references to one-line lambdas.
Before, a lot of switching and checking happened on each call to find and matches

- only keep operator and two flags in memor
- value, lowercasevalue and numericvalue were replaced by two functions
- indexPredicate and queryPredicate
@line-o line-o requested a review from a team as a code owner March 26, 2024 10:05
@line-o line-o requested review from dizzzz and reinhapa March 26, 2024 22:11
Copy link
Member

@reinhapa reinhapa left a comment

Choose a reason for hiding this comment

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

Ony a small change found ;-)

Copy link

sonarcloud bot commented Mar 28, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
64.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@line-o line-o requested a review from reinhapa March 30, 2024 21:04
@line-o
Copy link
Member Author

line-o commented May 2, 2024

@reinhapa I believe the changes you requested were addressed in the meantime

@line-o
Copy link
Member Author

line-o commented May 23, 2024

@reinhapa could you please re-review, I believe it's good to go

@adamretter adamretter self-requested a review May 23, 2024 21:29
Copy link
Contributor

@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.

I am not sure if this also addresses a bug or not? If it is just refactoring of existing code, then I have concerns:

  1. The newer code is more complex and difficult to follow; I don't see what advantage it offers over the existing code.
  2. The newer code exhibits symptoms of "information hiding". e.g. the variable caseSensitive (amongst others) is no longer knowable within an instance of the class at runtime; one side effect of that is that it will make debugging any future issues much more difficult.
  3. I haven't tested it with JMH myself, but my intuition is that the new code will perform worse that the older code. Has this been tested with JMH yet?

}
operator = getOperator(elem);
commutative = (operator == Operator.EQ || operator == Operator.NE);
commutativeNegate = (operator == Operator.GT || operator == Operator.LT || operator == Operator.GE || operator == Operator.LE);
Copy link
Contributor

Choose a reason for hiding this comment

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

commutativeNegate is a very strange name, at least in English. Perhaps notCommutative would be better to describe what you are trying to model?

@line-o
Copy link
Member Author

line-o commented Jul 31, 2024

commutativeNegate could be renamed to converse (see https://en.m.wikipedia.org/wiki/Converse_relation and https://en.m.wikipedia.org/wiki/Inequality_(mathematics) ).

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.

4 participants