nada-attia commented on code in PR #18941:
URL: https://github.com/apache/hudi/pull/18941#discussion_r3553650341
##########
hudi-io/src/main/java/org/apache/hudi/common/util/StringUtils.java:
##########
@@ -120,6 +122,31 @@ public static byte[] getUTF8Bytes(String str) {
return str.getBytes(StandardCharsets.UTF_8);
}
+ /**
+ * Serializable comparator ordering strings by their unsigned UTF-8 byte
representation, matching
+ * the ordering HFiles enforce (HBase's {@code CellComparatorImpl}). Unlike
+ * {@link String#compareTo(String)} (UTF-16), this stays consistent with
HFile ordering for
+ * non-ASCII / binary keys.
+ */
+ public static final Comparator<String> UTF8_LEXICOGRAPHIC_COMPARATOR =
+ (Comparator<String> & Serializable) StringUtils::compareUtf8Bytes;
+
+ /**
+ * Compares two strings by their unsigned UTF-8 byte order. See {@link
#UTF8_LEXICOGRAPHIC_COMPARATOR}.
+ */
+ public static int compareUtf8Bytes(String s1, String s2) {
+ byte[] b1 = getUTF8Bytes(s1);
Review Comment:
addressed both comments
--
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]