david-mollitor-db commented on code in PR #58675:
URL: https://github.com/apache/spark/pull/58675#discussion_r4053833804
##########
common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java:
##########
@@ -1147,13 +1148,12 @@ public UTF8String trimRight(UTF8String trimString) {
// the source string.
int trimEnd = numBytes - 1;
while (numChars > 0) {
- UTF8String searchChar = copyUTF8String(
Review Comment:
Good question, thanks! Those two int[numBytes] arrays
(stringCharLen/stringCharPos) in trimRight are pre-existing: UTF-8 can't be
scanned right-to-left directly, so trimRight walks the string once
left-to-right to record each character's position and length, then walks that
record backward. Dropping them would need a reverse UTF-8 scan (detecting
continuation bytes to find char boundaries from the end), which is a nice but
separate optimization. I'd prefer to keep this PR scoped to removing the
per-character copyUTF8String allocation and file that as a follow-up -- happy
to open a JIRA for it if you think it's worth pursuing.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]