airborne12 commented on code in PR #70592:
URL: https://github.com/apache/doris/pull/70592#discussion_r4624975518
##########
be/src/storage/index/inverted/query/exec/term_pattern.cpp:
##########
@@ -113,6 +174,12 @@ Status TermPattern::create(TermPatternKind kind,
std::string_view pattern, TermP
}
out->_scratch.reset(scratch);
out->_enumeration_prefix = regexp_enumeration_prefix(pattern);
+ // As for a glob: an expression with a prefix already stops where the
prefix ends, and CLucene
+ // checks the prefix only after this text, so '^cach.' would walk on past
"cach" through every
+ // later term that lacks "cach". Only an expression that enumerates the
whole dictionary keeps it.
+ if (out->_enumeration_prefix.empty()) {
+ out->_text = regexp_required_literal(pattern);
Review Comment:
Confirmed and fixed in 3aaa27d3893b.
Hyperscan compiles `terminated.c_str()`, so a raw NUL ends the expression,
while the literal was parsed from the whole `string_view`. Anchored patterns
had the same mismatch before this PR: `regexp_enumeration_prefix` passes the
full pattern to RE2, so `^cache` NUL `missing` got a prefix that left the term
`cache` out of the walk.
The fix derives both the enumeration prefix and the required literal from
`std::string_view(terminated.c_str())`, the text Hyperscan compiles.
Test: `TermPatternRegexpLiteral.RawNulEndsTheExpression` builds both
patterns with an explicit length. Before the fix it failed on both checks:
`required_text()` was `"cache\0missing"` while `matches("cache")` was true, and
`"cache"` did not start with the anchored prefix. After the fix it passes,
together with the other term pattern, regexp, wildcard and expansion unit tests
(205 tests in 55 suites).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]