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

    https://github.com/apache/spark/pull/7115#discussion_r34320221
  
    --- Diff: 
unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java ---
    @@ -262,4 +266,63 @@ public int hashCode() {
         }
         return result;
       }
    +
    +  private char[] getSoundexMapping() {
    +    return US_ENGLISH_MAPPING;
    +  }
    +
    +  private char map(final char ch) {
    +    final int index = ch - 'A';
    +    if (index < 0 || index >= getSoundexMapping().length) {
    +      throw new IllegalArgumentException("The character is not mapped: " + 
ch);
    +    }
    +    return getSoundexMapping()[index];
    +  }
    +
    +  private char getMappingCode(final String str, final int index) {
    +    // map() throws IllegalArgumentException
    +    final char mappedChar = map(str.charAt(index));
    +    // HW rule check
    +    if (index > 1 && mappedChar != '0') {
    +      final char hwChar = str.charAt(index - 1);
    +      if ('H' == hwChar || 'W' == hwChar) {
    +        final char preHWChar = str.charAt(index - 2);
    +        final char firstCode = map(preHWChar);
    +        if (firstCode == mappedChar || 'H' == preHWChar || 'W' == 
preHWChar) {
    +          return 0;
    +        }
    +      }
    +    }
    +    return mappedChar;
    +  }
    +
    +  private String soundex(String str) {
    --- End diff --
    
    `private String soundex(String str) {` => `public UTF8String soundex()`


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to