Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/12646#discussion_r139032904
--- Diff:
common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java ---
@@ -535,6 +585,51 @@ public UTF8String trimRight() {
}
}
+ /**
+ * Based on the given trim string, trim this string starting from right
end
+ * This method searches each character in the source string starting
from the right end, removes the character if it
+ * is in the trim string, stops at the first character which is not in
the trim string, returns the new string.
+ * @param trimString the trim character string
+ */
+ public UTF8String trimRight(UTF8String trimString) {
+ if (trimString == null)
+ return null;
+ int charIdx = 0;
+ // number of characters from the source string
+ int numChars = 0;
+ // array of character length for the source string
+ int[] stringCharLen = new int[numBytes];
+ // array of the first byte position for each character in the source
string
+ int[] stringCharPos = new int[numBytes];
+ // build the position and length array
+ while (charIdx < numBytes) {
+ stringCharPos[numChars] = charIdx;
+ stringCharLen[numChars]= numBytesForFirstByte(getByte(charIdx));
--- End diff --
add space before `=`
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]