-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[INLONG-10832][SDK] Transform SQL support Translate function #10863
[INLONG-10832][SDK] Transform SQL support Translate function #10863
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @lianghuan-xatu, thank you for submitting a PR to InLong 💖 We will respond as soon as possible ⏳
This seems to be your first PR 🌠 Please be sure to follow our Contribution Guidelines.
If you have any questions in the meantime, you can also ask us on the InLong Discussions 🔍
int replaceSize = replaceChars == null ? 0 : replaceChars.length(); | ||
for (int i = 0, size = originalStr.length(); i < size; i++) { | ||
char ch = originalStr.charAt(i); | ||
int index = findChars.indexOf(ch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to create a Map in advance to map the relationship between the find character and the replace character to avoid calling the indexOf
function in the for loop. The time complexity of the indexOf function is O(n)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, PTAL!
...rm-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/TranslateFunction.java
Show resolved
Hide resolved
...test/java/org/apache/inlong/sdk/transform/process/TestTransformStringFunctionsProcessor.java
Show resolved
Hide resolved
088185b
to
8a60287
Compare
8a60287
to
2bb75be
Compare
…10863) Co-authored-by: AloysZhang <[email protected]>
issue: #10832
Motivation
translate(originalString, searchString, replacementString)
translate function that replaces a sequence of characters in a string with another set of characters.
Example:
case1: translate("hello word!", "el", "EL")
case2: translate('ApaCHe Inlong', CH, ch)
Modifications
Verifying this change
(Please pick either of the following options)
This change is a trivial rework/code cleanup without any test coverage.
This change is already covered by existing tests, such as:
(please describe tests)
This change added tests and can be verified as follows:
(example:)
Documentation