cloud-fan commented on a change in pull request #26626: [SPARK-29986][SQL] 
Introduce java like string trim to UTF8String
URL: https://github.com/apache/spark/pull/26626#discussion_r349438483
 
 

 ##########
 File path: 
common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java
 ##########
 @@ -553,6 +553,34 @@ public UTF8String trim() {
     return copyUTF8String(s, e);
   }
 
+  /**
+   * Trims whitespaces (<= ASCII 32) from both ends of this string.
+   *
+   * Note that, this method is the same as java's {@link String#trim}, and 
different from
+   * {@link UTF8String#trim()} which only remove only spaces(= ASCII 32) from 
both ends.
+   *
+   * @return A UTF8String whose value is this UTF8String, with any leading and 
trailing white
+   * space removed, or this UTF8String if it has no leading or trailing 
whitespace.
+   *
+   */
+  public UTF8String trimAll() {
+    int s = 0;
+    // skip all of the whitespaces (<=0x20) in the left side
+    while (s < this.numBytes && getByte(s) <= 0x20) s++;
 
 Review comment:
   shall we use `' '` instead of `0x20`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to