mkaravel commented on code in PR #47771:
URL: https://github.com/apache/spark/pull/47771#discussion_r1729636043


##########
common/unsafe/src/main/java/org/apache/spark/sql/catalyst/util/CollationAwareUTF8String.java:
##########
@@ -550,6 +558,197 @@ public static UTF8String toTitleCase(final UTF8String 
target, final int collatio
       BreakIterator.getWordInstance(locale)));
   }
 
+  /**
+   * This 'HashMap' is introduced as a performance speedup. Since titlecasing 
a codepoint can result
+   * in more than a single codepoint, for correctness, we would use 
'UCharacter.toTitleCase(String)'
+   * which returns a 'String'. If we use 'UCharacter.toTitleCase(int)' (the 
version of the same
+   * function which converts a single codepoint to its titlecase codepoint), 
it would be faster than
+   * the previously mentioned version, but the problem here is that we don't 
handle when titlecasing
+   * a codepoint yields more than 1 codepoint. Since there are only 48 
codepoints that are mapped to
+   * more than 1 codepoint when titlecased, they are precalculated here, so 
that the faster function
+   * for titlecasing could be used in combination with this 'HashMap' in the 
method
+   * 'appendCodepointToTitleCase'.
+   */
+  private static final HashMap<Integer, String> 
codepointOneToManyTitleCasePrecalculation =
+    new HashMap<>(){{
+    put(223, "Ss");

Review Comment:
   In case you need more than four hex digits for the integer, just use however 
many you need (the idea is to use at least four hex digits, not less, and also 
not more than needed if more than 4).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to