-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INLONG-11190][SDK] Optimize Transform SDK Translate Function (#11191)
- Loading branch information
Showing
1 changed file
with
2 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ | |
* find_chars: A string containing the characters to be replaced. | ||
* replace_chars: A string containing the characters to substitute. | ||
* examples: | ||
* case1: translate(email, '@', '.') -> original_expression: [email protected] target_expression: harry.inlong.com | ||
* case1: translate([email protected], '@', '.') -> original_expression: [email protected] target_expression: harry.inlong.com | ||
* case2: translate(hello WorD, 'WD', 'wd') -> original_expression: hello WorD target_expression: hello word | ||
*/ | ||
@TransformFunction(names = {"translate"}) | ||
|
@@ -108,9 +108,7 @@ private Map<Character, Character> parseReplacementMap(String findChars, String r | |
return ImmutableMap.of(); | ||
} | ||
|
||
final int findSize = findChars == null ? 0 : findChars.length(); | ||
final int replaceSize = replaceChars == null ? 0 : replaceChars.length(); | ||
final int commonSize = Math.min(findSize, replaceSize); | ||
final int commonSize = Math.min(findChars.length(), replaceChars.length()); | ||
// Create a map to store character replacements | ||
Map<Character, Character> replacementMap = new HashMap<>(); | ||
for (int i = 0; i < commonSize; i++) { | ||
|