spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenghao-intel <...@git.apache.org>
Subject [GitHub] spark pull request #12646: [SPARK-14878][SQL] Trim characters string functio...
Date Wed, 31 Aug 2016 10:20:52 GMT
Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12646#discussion_r76962088
  
    --- Diff: common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java ---
    @@ -488,6 +543,28 @@ public UTF8String trimLeft() {
         }
       }
     
    +  /**
    +   * Removes all specified trim character from the beginning of a string
    +   * @param trimChar the trim character
    +   */
    +  public UTF8String trimLeft(UTF8String trimChar) {
    +    int numTrimBytes = trimChar.numBytes;
    +    if (numTrimBytes == 0) {
    +      return this;
    +    }
    +    int s = 0;
    +    // skip all the consecutive matching character in the left side
    +    while(s < this.numBytes && s == this.find(trimChar, s)) {
    +      s += numTrimBytes;
    +    }
    +    if (s == this.numBytes) {
    +      // empty string
    +      return UTF8String.fromBytes(new byte[0]);
    --- End diff --
    
    `UTF8String.EMPTY_UTF8` instead?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message