lvyanquan commented on code in PR #4491:
URL: https://github.com/apache/flink-cdc/pull/4491#discussion_r3711078614
##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/functions/impl/StringFunctions.java:
##########
@@ -62,6 +65,72 @@ public static String regexpReplace(String str, String regex,
String replacement)
}
}
+ /** Returns a string extracted with a specified regular expression and
capture group index. */
+ public static String regexpExtract(String str, String regex) {
+ return regexpExtract(str, regex, 0);
+ }
+
+ public static String regexpExtract(String str, String regex, Number
extractIndex) {
+ if (extractIndex == null || extractIndex.longValue() < 0) {
+ return null;
+ }
+ Matcher matcher = getRegexpMatcher(str, regex);
Review Comment:
`getRegexpMatcher()` calls `Pattern.compile(regex)` for every record. Since
regexes in YAML transforms are usually constant, this adds unnecessary CPU
overhead to the per-record hot path. Please use a bounded
`ThreadLocalCache<String, Pattern>` while preserving the current invalid-regex
behavior.
--
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]