HyukjinKwon commented on code in PR #45816:
URL: https://github.com/apache/spark/pull/45816#discussion_r1548779756


##########
common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java:
##########
@@ -447,6 +447,37 @@ private UTF8String toUpperCaseSlow() {
     return fromString(toString().toUpperCase());
   }
 
+  /**
+   * Optimized lowercase comparison for UTF8_BINARY_LCASE collation
+   */
+  public int compareLowercase(UTF8String other) {
+    int curr;
+    for (curr = 0; curr < numBytes && curr < other.numBytes; curr++) {
+      byte left = getByte(curr);
+      byte right = other.getByte(curr);
+      if (numBytesForFirstByte(left) != 1 || numBytesForFirstByte(right) != 1) 
{
+        return compareLowercaseSuffixSlow(other, curr);
+      }
+      int lowerLeft = Character.toLowerCase(left);
+      int lowerRight = Character.toLowerCase(right);
+      if (lowerLeft > 127 || lowerRight > 127) {
+        return compareLowercaseSuffixSlow(other, curr);
+      }
+      if (lowerLeft != lowerRight) {
+        return lowerLeft - lowerRight;
+      }
+    }
+    return numBytes - other.numBytes;
+  }
+
+  private int compareLowercaseSuffixSlow(UTF8String other, int pref) {
+    UTF8String suffixLeft = UTF8String.fromAddress(base, offset + pref,
+            numBytes - pref);

Review Comment:
   Can we use 2-spaced intentation? See "Code style guide" at 
https://spark.apache.org/contributing.html 



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