cshuo commented on code in PR #13742:
URL: https://github.com/apache/hudi/pull/13742#discussion_r2300957205


##########
hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/io/CustomMerger.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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 org.apache.hudi.io;
+
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieRecordMerger;
+import org.apache.hudi.common.util.collection.Pair;
+
+import org.apache.avro.Schema;
+
+import java.io.IOException;
+import java.util.UUID;
+
+public class CustomMerger implements HoodieRecordMerger {
+  private static final String STRATEGY_ID = UUID.randomUUID().toString();
+
+  public static String getStrategyId() {
+    return STRATEGY_ID;
+  }
+
+  @Override
+  public Pair<HoodieRecord, Schema> merge(HoodieRecord older, Schema 
oldSchema, HoodieRecord newer, Schema newSchema, TypedProperties props) throws 
IOException {
+    Long olderTimestamp = (Long) older.getOrderingValue(oldSchema, props, new 
String[0]);
+    Long newerTimestamp = (Long) newer.getOrderingValue(oldSchema, props, new 
String[0]);

Review Comment:
   `oldSchema` -> `newSchema`?



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieWriteMergeHandle.java:
##########
@@ -149,6 +158,7 @@ public HoodieWriteMergeHandle(HoodieWriteConfig config, 
String instantTime, Hood
   public HoodieWriteMergeHandle(HoodieWriteConfig config, String instantTime, 
String partitionPath,
                                 String fileId, HoodieTable<T, I, K, O> 
hoodieTable, TaskContextSupplier taskContextSupplier) {
     super(config, instantTime, partitionPath, fileId, hoodieTable, 
taskContextSupplier, true);
+    this.orderingFields = ConfigUtils.getOrderingFields(config.getProps());

Review Comment:
   can we also initialize `readerContext` in this constructor and make the 
`readerContext` final? This constructor is for fg based handle, seems we can 
pass the `readerContext` in parameters.



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieWriteMergeHandle.java:
##########
@@ -120,6 +125,8 @@ public HoodieWriteMergeHandle(HoodieWriteConfig config, 
String instantTime, Hood
     super(config, instantTime, hoodieTable, partitionPath, fileId, 
taskContextSupplier, baseFile, keyGeneratorOpt, false);
     populateIncomingRecordsMap(recordItr);
     initMarkerFileAndFileWriter(fileId, partitionPath);
+    this.readerContext = 
hoodieTable.getReaderContextFactoryForWrite().getContext();

Review Comment:
   There is duplicate re-initialization for `readerContext` after this change.



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