lokeshj1703 commented on code in PR #8514:
URL: https://github.com/apache/hudi/pull/8514#discussion_r1182258293
##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/UtilHelpers.java:
##########
@@ -191,15 +190,11 @@ public static SchemaPostProcessor
createSchemaPostProcessor(
}
- public static Option<Transformer> createTransformer(List<String> classNames)
throws IOException {
+ public static Option<Transformer> createTransformer(Option<List<String>>
classNamesOpt) throws IOException {
try {
- List<Transformer> transformers = new ArrayList<>();
- for (String className :
Option.ofNullable(classNames).orElse(Collections.emptyList())) {
- transformers.add(ReflectionUtils.loadClass(className));
- }
- return transformers.isEmpty() ? Option.empty() : Option.of(new
ChainedTransformer(transformers));
+ return classNamesOpt.map(classNames -> classNames.isEmpty() ? null : new
ChainedTransformer(classNames));
Review Comment:
We can only return null inside `map` function as it expects the value. I can
add a new API with something like `mapIf` if we want to clean this code further.
--
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]