uvashishtha opened a new pull request, #29375:
URL: https://github.com/apache/flink/pull/29375
## What is the purpose of the change
`PARSE_URL(url, 'QUERY', key)` compiled a new regex `Pattern` for the query
parameter on every row, even though the pattern depends only on `key`. This
change caches the pattern in a `ThreadLocalCache` keyed on `key`, matching how
`URL_CACHE` already caches the parsed URL in the same method.
## Brief change log
- Added `QUERY_PARAM_PATTERN_CACHE` (`ThreadLocalCache`) to
`SqlFunctionUtils`
- `SqlFunctionUtils#parseUrl(String, String, String)` looks up the pattern
from the cache instead of compiling it per call
## Verifying this change
This change added tests and can be verified as follows:
- Added
`SqlFunctionUtilsTest#testParseUrlQueryParameterWithDifferentKeys`, which looks
up several keys on the same thread (including one with a regex metacharacter)
to verify that each key resolves to its own pattern and that keys stay quoted
- Existing coverage in `ScalarFunctionsTest#testParseUrl` passes unchanged
JMH (JDK 17, single thread, 3 forks, URLs with 8 query parameters):
| Distinct keys | Before | After | Allocation per call |
|---|---|---|---|
| 1 (constant key) | 249.9 ± 1.6 ns | 65.1 ± 1.4 ns | 1902 B → 262 B |
| 16 (fits the 64-entry cache) | 665 ± 98 ns | 530 ± 21 ns | 1917 B → 262 B |
| 256 (exceeds the cache) | 700 ± 98 ns | 702 ± 72 ns | 1950 B → 1990 B |
When keys exceed the cache size there is no measurable regression.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): yes
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
Generated-by: Claude Opus 5.5
--
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]