GitHub user LosD opened a pull request:
https://github.com/apache/metamodel/pull/115
Anchor WildcardPattern to start
This makes sure the `WildcardPattern` anchors its test to the start of the
string, not only the end.
This comes with a minor performance penalty (quick test said 5-10%), but I
think correctness trumps speed here.
I would have liked to compare speed with pre-compiled regexes
(`Pattern.quote()` the operand, replace `%` with `.*?` and anchor it with `^`
and `$`), but if the LIKE operand is inside a `SelectItem`, that would mean
compiling a new regex pattern for every row, which would probably be _very_
expensive, so I opted not to try. There seem to be some similar optimization of
the IN operator, so I might be wrong, though.
Fixes METAMODEL-1103
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/LosD/metamodel
METAMODEL-1103/anchor-string-start
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/metamodel/pull/115.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #115
----
commit e993e9483a9daf0e0f603362d31fbc231a344ab7
Author: Dennis Du Krøger <[email protected]>
Date: 2016-07-12T14:28:00Z
METAMODEL-1103: Anchor WildcardPattern to start
This makes sure the WildcardPattern anchors its test to the start of
the string, not only the end.
This comes with a minor performance penalty (quick test said 5-10% ),
but I think correctness trumps speed here.
I would have liked to compare speed with pre-compiled regexes
(`Pattern.quote()` the operand, replace `%` with `.*?` and anchor it
with `^` and `$`), but if the LIKE operand is inside a SelectItem,
that would mean compiling a new regex pattern for every row, which
would probably be _very_ expensive, so I opted not to try. There seem
to be some similar optimization of the IN operator, so I might be
wrong.
Fixes METAMODEL-1103
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---