wuchong commented on code in PR #515:
URL: https://github.com/apache/fluss/pull/515#discussion_r2256905987


##########
fluss-common/src/main/java/com/alibaba/fluss/predicate/CompareUtils.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.alibaba.fluss.predicate;
+
+import com.alibaba.fluss.row.BinaryString;
+import com.alibaba.fluss.types.DataType;
+
+import static java.lang.Math.min;
+
+/* This file is based on source code of Apache Paimon Project 
(https://paimon.apache.org/), licensed by the Apache
+ * Software Foundation (ASF) under the Apache License, Version 2.0. See the 
NOTICE file distributed with this work for
+ * additional information regarding copyright ownership. */
+
+/** Utils for comparator. */
+public class CompareUtils {
+    private CompareUtils() {}
+
+    public static int compareLiteral(DataType type, Object v1, Object v2) {
+        if (v1 instanceof Comparable) {
+            // because BinaryString can not serialize so v1 or v2 may be 
BinaryString convert to
+            // String for compare
+            if (v1 instanceof BinaryString) {
+                v1 = ((BinaryString) v1).toString();
+            }
+            if (v2 instanceof BinaryString) {
+                v2 = ((BinaryString) v2).toString();
+            }
+            return ((Comparable<Object>) v1).compareTo(v2);

Review Comment:
   @Alibaba-HZY If `BinaryString` is not serializable, the predicate should use 
`String` literals, and the comparison parameters should be of type `String` 
rather than `BinaryString`. That means we still don't need to cast 
`BinaryString` to `String`.



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

Reply via email to