uros-db commented on code in PR #45421:
URL: https://github.com/apache/spark/pull/45421#discussion_r1516381847


##########
common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java:
##########
@@ -384,27 +387,47 @@ public boolean startsWith(final UTF8String prefix) {
   }
 
   public boolean startsWith(final UTF8String prefix, int collationId) {
-    if (CollationFactory.fetchCollation(collationId).isBinaryCollation) {
+    if (collationId == CollationFactory.DEFAULT_COLLATION_ID) {
       return this.startsWith(prefix);
     }
     if (collationId == CollationFactory.LOWERCASE_COLLATION_ID) {
       return this.toLowerCase().startsWith(prefix.toLowerCase());
     }
-    return matchAt(prefix, 0, collationId);
+    if (prefix.numBytes == 0 || this.numBytes == 0) return prefix.numBytes==0;
+
+    String prefixString = 
StandardCharsets.UTF_8.decode(prefix.getByteBuffer()).toString(),
+            patternString = 
StandardCharsets.UTF_8.decode(this.getByteBuffer()).toString();
+
+    StringSearch search = new StringSearch(prefixString,
+            new StringCharacterIterator(patternString),
+            (RuleBasedCollator) 
CollationFactory.fetchCollation(collationId).collator
+    );
+
+    return search.first()==0;
   }
 
   public boolean endsWith(final UTF8String suffix) {
     return matchAt(suffix, numBytes - suffix.numBytes);
   }
 
   public boolean endsWith(final UTF8String suffix, int collationId) {
-    if (CollationFactory.fetchCollation(collationId).isBinaryCollation) {
+    if (collationId == CollationFactory.DEFAULT_COLLATION_ID) {

Review Comment:
   (see comment above)



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to