Add fn:regex and fn:compiled-regex-record#2670
Merged
Merged
Conversation
Member
Author
|
A deliberate deviation from the spec: the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These changes add support for the new
fn:regexfunction and the built-infn:compiled-regex-recordtype.fn:regexis implemented by constructing a map ofFuncItemclosures over the constant pattern and flags. Each closure body is a freshStandardFuncinstance (FnMatches,FnTokenize, etc.). Prior to this change, each such instance had its own per-instance regex cache. The per-instance cache has been replaced by a single per-query cache onQueryContext, shared by allRegExFninstances within a query. The pattern compiled eagerly infn:regexis therefore found immediately by any subsequent member function call - fulfilling the spec's intent of compiling once and reusing.RegExpr,GroupInfo, andGroupScannerwere moved from inner classes ofRegExFnto a new top-level classorg.basex.query.util.regex.RegExpr. This was done in order to avoidQueryContextdepending on a type defined inside a concrete function implementation. The only code changes are visibility adjustments required by the package move: the class, its constructor, the pattern field, and the two accessor methods are now public (they were package-private, but callers inorg.basex.query.func.fnandorg.basex.queryrequire access), algorithmic logic is identical.This fixes QT4 tests
Keywords-fn-regex-1fo-test-fn-regex-001fo-test-fn-regex-002fo-test-fn-regex-004Additionally, a test has been added to verify that constructor functions exist for all built-in record types, and constructor functions have been added where they were missing.