Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7533#discussion_r35331712
  
    --- Diff: 
unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java ---
    @@ -352,6 +351,196 @@ public int indexOf(UTF8String v, int start) {
         return -1;
       }
     
    +  private enum ByteType {FIRSTBYTE, MIDBYTE, SINGLEBYTECHAR};
    +
    +  private ByteType checkByteType(Byte b) {
    +    int firstTwoBits = (b >>> 6) & 0x03;
    +    if (firstTwoBits == 3) {
    +       return ByteType.FIRSTBYTE;
    +     } else if (firstTwoBits == 2) {
    +      return ByteType.MIDBYTE;
    +    } else {
    +      return ByteType.SINGLEBYTECHAR;
    +    }
    +  }
    +
    +  /**
    +   * Return the first byte position for a given byte which shared the same 
code point.
    +   * @param bytePos any byte within the code point
    +   * @return the first byte position of a given code point, throw 
exception if not a valid UTF8 str
    +   */
    +  private int firstOfCurrentCodePoint(int bytePos) {
    +    while (bytePos >= 0) {
    +      if (ByteType.FIRSTBYTE == checkByteType(getByte(bytePos))
    --- End diff --
    
    use a tmp variable for the result of `checkByteType(getByte(bytePos))`, as 
it will be used later.


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