uros-db commented on code in PR #47771:
URL: https://github.com/apache/spark/pull/47771#discussion_r1718411918
##########
common/unsafe/src/main/java/org/apache/spark/sql/catalyst/util/CollationAwareUTF8String.java:
##########
@@ -1267,6 +1268,119 @@ public static UTF8String[] icuSplitSQL(final UTF8String
string, final UTF8String
return strings.toArray(new UTF8String[0]);
}
+ /**
+ * Title casing a string according to a new behaviour.
+ * Iterates over the string and title cases the first character in each
word, and lowercases
+ * every other character.
+ * Handles lowercasing greek sigma(Σ) separately, taking into account if
+ * it should be a small final sigma(ς) or small non-final sigma(σ).
+ * Words are separated by ASCII space(\u0020).
+ *
+ * @param target UTF8String to be title cased
+ * @return title cased target
+ */
+ public static UTF8String toTitleCaseICU(UTF8String target) {
+
+ Iterator<Integer> codepointIterator = target.
+
codePointIterator(CodePointIteratorType.CODE_POINT_ITERATOR_MAKE_VALID);
+
+ // building the title cased target with sb
+ StringBuilder sb=new StringBuilder();
+ // newWord is true if the current character is the beginning of a word,
false otherwise
+ // it is true on the i-th character if i==0 or target at (i-1)-th
character is ' '
Review Comment:
```suggestion
// `newWord` is true if the current character is at the beginning of a
word, false otherwise.
// `newWord` is true for the i-th character if: i == 0 or target at
(i-1)-th character is an empty char (' ').
```
implementation comments should generally resemble proper sentences (as
clearly as possible)
##########
common/unsafe/src/main/java/org/apache/spark/sql/catalyst/util/CollationAwareUTF8String.java:
##########
@@ -1267,6 +1268,119 @@ public static UTF8String[] icuSplitSQL(final UTF8String
string, final UTF8String
return strings.toArray(new UTF8String[0]);
}
+ /**
+ * Title casing a string according to a new behaviour.
+ * Iterates over the string and title cases the first character in each
word, and lowercases
+ * every other character.
+ * Handles lowercasing greek sigma(Σ) separately, taking into account if
+ * it should be a small final sigma(ς) or small non-final sigma(σ).
+ * Words are separated by ASCII space(\u0020).
+ *
+ * @param target UTF8String to be title cased
+ * @return title cased target
+ */
+ public static UTF8String toTitleCaseICU(UTF8String target) {
+
+ Iterator<Integer> codepointIterator = target.
+
codePointIterator(CodePointIteratorType.CODE_POINT_ITERATOR_MAKE_VALID);
+
+ // building the title cased target with sb
+ StringBuilder sb=new StringBuilder();
+ // newWord is true if the current character is the beginning of a word,
false otherwise
+ // it is true on the i-th character if i==0 or target at (i-1)-th
character is ' '
Review Comment:
(to avoid duplicate comments on the PR - this goes for all instances below)
--
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]