Github user tarekauel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6762#discussion_r33698802
  
    --- Diff: 
unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java ---
    @@ -159,6 +162,77 @@ public UTF8String toLowerCase() {
         return UTF8String.fromString(toString().toLowerCase());
       }
     
    +  public UTF8String trim() {
    +    return UTF8String.fromString(toString().trim());
    +  }
    +
    +  public UTF8String trimLeft() {
    +    return UTF8String.fromString(StringUtils.stripStart(toString(), " "));
    +  }
    +
    +  public UTF8String trimRight() {
    +    return UTF8String.fromString(StringUtils.stripEnd(toString(), " "));
    +  }
    +
    +  public UTF8String reverse() {
    +    return UTF8String.fromString(StringUtils.reverse(toString()));
    +  }
    +
    +  /**
    +   * Returns the position of the first occurrence of substr in
    +   * current string from the specified position (0-based index).
    +   *
    +   * @param v the string to be searched
    +   * @param start the start position of the current string for searching
    +   * @return the position of the first occurrence of substr, if not found, 
-1 returned.
    +   */
    +  public int instr(UTF8String v, int start) {
    --- End diff --
    
    This function looks super complex for me. Couldn't we just use `contains` 
and `startsWith` of `UTF8String`. We could add `instr` to `UTF8String`, return 
`i` for `startsWith` and do the `i == prefix.length` in `contains`. The 
comparison logic is duplicated at the moment.
    
    Start is an offset specified in `bytes`, isn't it (same as 
`UTF8String.startsWith`? The result is specified as byte offset, is that 
expected?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to