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

    https://github.com/apache/spark/pull/7186#discussion_r35187145
  
    --- 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 --
    
    When you call the arrayEquals, the arrayEquals start from the position in 
the set your code already scanned, the overall time consumption will be 2 times 
than scan one time to get the result. This implement is similar with 1. split 
2. check match. If the set the big, the time cost will be large. I think you 
can compare the byte onebyone and find the index in one execution. 


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