cshuo commented on code in PR #17668:
URL: https://github.com/apache/hudi/pull/17668#discussion_r2645036619
##########
hudi-common/src/main/java/org/apache/hudi/common/util/OrderingValueUtils.java:
##########
@@ -0,0 +1,47 @@
+package org.apache.hudi.common.util;
+
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.util.Utf8;
+import org.apache.hudi.avro.HoodieAvroUtils;
+import org.apache.hudi.common.util.collection.ImmutablePair;
+import org.apache.hudi.common.util.collection.Pair;
+
+import java.math.BigDecimal;
+/*
Review Comment:
license should be on top of the file.
##########
hudi-common/src/main/java/org/apache/hudi/common/model/DefaultHoodieRecordPayload.java:
##########
@@ -165,7 +163,7 @@ public Option<Map<String, String>> getMetadata() {
}
protected boolean needUpdatingPersistedRecord(IndexedRecord currentValue,
- IndexedRecord incomingRecord,
Properties properties) {
+ Object incomingRecord,
Properties properties) {
Review Comment:
we can directly update the type to Option<IndexedRecord>? you can refer the
changes in master branch
https://github.com/apache/hudi/blob/43569426895d68f9e411e542f3c535d2dca00236/hudi-common/src/main/java/org/apache/hudi/common/model/DefaultHoodieRecordPayload.java#L153
##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/table/ITTestHoodieDataSource.java:
##########
@@ -2148,6 +2274,9 @@ void testReadWithParquetPredicatePushDown() {
private enum ExecMode {
BATCH, STREAM
}
+ private enum SceneType {
Review Comment:
not needed actually, boolean is enough since the testing logic is same for
`SCENE01`, `SCENE03`
##########
hudi-common/src/main/java/org/apache/hudi/common/util/OrderingValueUtils.java:
##########
@@ -0,0 +1,47 @@
+package org.apache.hudi.common.util;
+
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.util.Utf8;
+import org.apache.hudi.avro.HoodieAvroUtils;
+import org.apache.hudi.common.util.collection.ImmutablePair;
+import org.apache.hudi.common.util.collection.Pair;
+
+import java.math.BigDecimal;
+/*
+ * 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.
+ */
+/**
+ * Utils for orderingValue process.
+ */
+public class OrderingValueUtils {
+ public static Pair<Comparable, Comparable>
canonicalizeOrderingValue(Comparable oldOrder, Comparable incomingOrder) {
Review Comment:
add some documentation to the method.
##########
hudi-common/src/main/java/org/apache/hudi/common/table/log/HoodieMergedLogRecordScanner.java:
##########
@@ -282,11 +275,12 @@ protected void processNextDeletedRecord(DeleteRecord
deleteRecord) {
Comparable curOrderingVal =
oldRecord.getOrderingValue(this.readerSchema,
this.hoodieTableMetaClient.getTableConfig().getProps());
Comparable deleteOrderingVal = deleteRecord.getOrderingValue();
+ Pair<Comparable, Comparable> comparablePair =
OrderingValueUtils.canonicalizeOrderingValue(curOrderingVal, deleteOrderingVal);
// Checks the ordering value does not equal to 0
// because we use 0 as the default value which means natural order
boolean choosePrev = !deleteOrderingVal.equals(0)
- && ReflectionUtils.isSameClass(curOrderingVal, deleteOrderingVal)
- && curOrderingVal.compareTo(deleteOrderingVal) > 0;
+ && ReflectionUtils.isSameClass(comparablePair.getLeft(),
comparablePair.getRight())
Review Comment:
we can reassign `curOrderingVal` and `deleteOrderingVal` with canonicalized
value, to improve the readability of code.
--
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]