danny0405 commented on code in PR #13699:
URL: https://github.com/apache/hudi/pull/13699#discussion_r2271898808
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieMergeHandleFactory.java:
##########
@@ -60,21 +60,35 @@ public static <T, I, K, O> HoodieMergeHandle<T, I, K, O>
create(
String partitionPath,
String fileId,
TaskContextSupplier taskContextSupplier,
- Option<BaseKeyGenerator> keyGeneratorOpt) {
+ Option<BaseKeyGenerator> keyGeneratorOpt,
+ HoodieReaderContext<T> readerContext) {
boolean isFallbackEnabled = writeConfig.isMergeHandleFallbackEnabled();
Pair<String, String> mergeHandleClasses =
getMergeHandleClassesWrite(operationType, writeConfig, table);
String logContext = String.format("for fileId %s and partition path %s at
commit %s", fileId, partitionPath, instantTime);
LOG.info("Create HoodieMergeHandle implementation {} {}",
mergeHandleClasses.getLeft(), logContext);
Class<?>[] constructorParamTypes = new Class<?>[] {
+ HoodieWriteConfig.class, String.class, HoodieTable.class,
Iterator.class,
+ String.class, String.class, TaskContextSupplier.class, Option.class,
HoodieReaderContext.class
+ };
+
+ Class<?>[] legacyConstructorParamTypes = new Class<?>[] {
HoodieWriteConfig.class, String.class, HoodieTable.class,
Iterator.class,
String.class, String.class, TaskContextSupplier.class, Option.class
};
- return instantiateMergeHandle(
- isFallbackEnabled, mergeHandleClasses.getLeft(),
mergeHandleClasses.getRight(), logContext, constructorParamTypes,
- writeConfig, instantTime, table, recordItr, partitionPath, fileId,
taskContextSupplier, keyGeneratorOpt);
+ try {
+ return instantiateMergeHandle(
+ isFallbackEnabled, mergeHandleClasses.getLeft(),
mergeHandleClasses.getRight(), logContext, constructorParamTypes,
+ writeConfig, instantTime, table, recordItr, partitionPath, fileId,
taskContextSupplier, keyGeneratorOpt, readerContext);
+ } catch (Exception e) {
+ // Fallback to legacy constructor if the new one fails
+ LOG.warn("Failed to instantiate HoodieMergeHandle with new constructor,
falling back to legacy constructor: {}", e.getMessage());
Review Comment:
the catch exception fallback is hacky, can we match the class name
`FileGroupReaderBasedMergeHandle.class.getName` to invoke different
constructors.
--
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]