yuxiqian commented on code in PR #3677:
URL: https://github.com/apache/flink-cdc/pull/3677#discussion_r1904984067
##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/functions/SystemFunctionUtils.java:
##########
@@ -846,4 +846,49 @@ private static String castObjectIntoString(Object object) {
}
return String.valueOf(object);
}
+
+ private static int universalCompares(Object lhs, Object rhs) {
+ Class<?> leftClass = lhs.getClass();
+ Class<?> rightClass = rhs.getClass();
+ if (leftClass.equals(rightClass) &&
Comparable.class.isAssignableFrom(leftClass)) {
+ return ((Comparable) lhs).compareTo(rhs);
+ } else if (Number.class.isAssignableFrom(leftClass)
+ && Number.class.isAssignableFrom(rightClass)) {
+ return Double.compare(((Number) lhs).doubleValue(), ((Number)
rhs).doubleValue());
+ } else {
+ throw new RuntimeException(
+ "Comparison of unsupported data types: "
+ + leftClass.getName()
+ + " and "
+ + rightClass.getName());
+ }
Review Comment:
Will it be faster if we use `obj instanceof` instead of `isAssignableFrom`?
--
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]