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

    https://github.com/apache/spark/pull/7186#discussion_r36114495
  
    --- Diff: 
unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java ---
    @@ -231,6 +233,36 @@ public UTF8String toLowerCase() {
       }
     
       /**
    +   * Returns the index of the string `match` in this String. This string 
has to be a comma separated
    +   * list. If `match` contains a comma 0 will be returned. If the `match` 
isn't part of this String,
    +   * 0 will be returned, else the index of match (1-based index)
    +   */
    +  public int findInSet(UTF8String match) {
    +    if (match.contains(COMMA_UTF8)) {
    +      return 0;
    +    }
    +
    +    int n = 1, lastComma = -1;
    +    for (int i = 0; i < numBytes; i++) {
    +      if (getByte(i) == (byte) ',') {
    +        if (i - (lastComma + 1) == match.numBytes &&
    +            ByteArrayMethods.arrayEquals(base, offset + (lastComma + 1), 
match.base, match.offset,
    +                match.numBytes)) {
    --- End diff --
    
    The current approach have the optimization of check the length of match 
first, so it actually will not call arrayEquals many times in practice. It's 
good to me.


---
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