danny0405 commented on code in PR #7752: URL: https://github.com/apache/hudi/pull/7752#discussion_r1105614300
########## hudi-common/src/main/java/org/apache/hudi/common/table/log/AbstractHoodieLogRecordReader.java: ########## @@ -807,16 +809,17 @@ private ClosableIteratorWithSchema<HoodieRecord> getRecordsIterator( Option<Pair<Function<HoodieRecord, HoodieRecord>, Schema>> schemaEvolutionTransformerOpt = composeEvolvedSchemaTransformer(dataBlock); + // In case when schema has been evolved original persisted records will have to be // transformed to adhere to the new schema - if (schemaEvolutionTransformerOpt.isPresent()) { - return ClosableIteratorWithSchema.newInstance( - new CloseableMappingIterator<>(blockRecordsIterator, - schemaEvolutionTransformerOpt.get().getLeft()), - schemaEvolutionTransformerOpt.get().getRight()); - } else { - return ClosableIteratorWithSchema.newInstance(blockRecordsIterator, dataBlock.getSchema()); - } + Function<HoodieRecord, HoodieRecord> transformer = + schemaEvolutionTransformerOpt.map(Pair::getLeft) + .orElse(Function.identity()); + + Schema schema = schemaEvolutionTransformerOpt.map(Pair::getRight) + .orElse(dataBlock.getSchema()); + Review Comment: The code looks clean but for use case when `schemaEvolutionTransformerOpt.isPresent()` is false, there is unnecessary invocation of `Function.identity()`. -- 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: commits-unsubscr...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org