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

Make LIKE predicate index aware #18289

Merged

Conversation

alex-dukhno
Copy link
Contributor

Closes #14561

@alex-dukhno alex-dukhno added this to the 4.2 milestone Feb 24, 2021
@alex-dukhno alex-dukhno self-assigned this Feb 24, 2021
@mmedenjak mmedenjak added the Source: Internal PR or issue was opened by an employee label Feb 24, 2021
@taburet
Copy link
Contributor

taburet commented Feb 25, 2021

Regarding ILIKE support, looks like we can use the same trick, but the lower bound should be uppercased while the upper bound should be lowercased. No, we can't :)

@hazelcast hazelcast deleted a comment from hz-devops-test Feb 25, 2021
@alex-dukhno alex-dukhno force-pushed the v4.2/query/LIKE-predicate-and-index branch from 7e2695c to b105032 Compare February 26, 2021 09:26
@hazelcast hazelcast deleted a comment from hz-devops-test Feb 26, 2021
@hazelcast hazelcast deleted a comment from hz-devops-test Feb 26, 2021
@hazelcast hazelcast deleted a comment from hz-devops-test Feb 26, 2021
@alex-dukhno alex-dukhno requested a review from taburet March 1, 2021 07:11
@taburet
Copy link
Contributor

taburet commented Mar 1, 2021

Looks like there are no tests targeting indexed LIKE queries specifically to make sure the queries are really returning only the entries matching the prefix.

@hz-devops-test
Copy link

The job Hazelcast-pr-builder of your PR failed.
Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log file
--------------------------
-------TEST FAILURE-------
--------------------------
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   ConfiguredBehaviourTest.testReconnectModeASYNCSingleMemberStartLate:266 ? HazelcastClientOffline
[INFO] 
[ERROR] Tests run: 36164, Failures: 0, Errors: 1, Skipped: 988
[INFO] 

[ERROR] There are test failures.

@alex-dukhno
Copy link
Contributor Author

Test failure is not related and filled in #18323

char c = expression.charAt(i);
if (c == '\\') {
escape = true;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if I have an expression "\\%". Then the \ is actually escaping the second \? But the algorithm will consider like it is escaping the % symbol?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch added tests and fixed

@Override
public Set<QueryableEntry> filter(QueryContext queryContext) {
Index index = queryContext.matchIndex(attributeName, QueryContext.IndexMatchHint.PREFER_ORDERED);
String indexPrefix = expression.substring(0, expression.length() - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

As I understand we cut the % here. But what if we have trailing whitespace? Is it possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alex-dukhno alex-dukhno merged commit cef51f4 into hazelcast:master Mar 3, 2021
@alex-dukhno alex-dukhno deleted the v4.2/query/LIKE-predicate-and-index branch March 3, 2021 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LIKE predicate and index
5 participants