HuangZhenQiu commented on code in PR #18406:
URL: https://github.com/apache/hudi/pull/18406#discussion_r3007318563
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/source/reader/function/HoodieSplitReaderFunction.java:
##########
@@ -71,28 +62,41 @@ public HoodieSplitReaderFunction(
String mergeType,
List<ExpressionPredicates.Predicate> predicates,
boolean emitDelete) {
+ this(configuration, tableSchema, requiredSchema, internalSchemaManager,
mergeType, predicates, emitDelete, NO_LIMIT);
+ }
+ public HoodieSplitReaderFunction(
+ Configuration configuration,
+ HoodieSchema tableSchema,
+ HoodieSchema requiredSchema,
+ InternalSchemaManager internalSchemaManager,
+ String mergeType,
+ List<ExpressionPredicates.Predicate> predicates,
+ boolean emitDelete,
+ long limit) {
+ super(configuration, predicates, internalSchemaManager, limit, emitDelete);
ValidationUtils.checkArgument(tableSchema != null, "tableSchema can't be
null");
ValidationUtils.checkArgument(requiredSchema != null, "requiredSchema
can't be null");
ValidationUtils.checkArgument(internalSchemaManager != null,
"internalSchemaManager can't be null");
this.tableSchema = tableSchema;
this.requiredSchema = requiredSchema;
- this.internalSchemaManager = internalSchemaManager;
- this.configuration = configuration;
- this.writeConfig = FlinkWriteClients.getHoodieClientConfig(configuration);
- this.predicates = predicates;
this.mergeType = mergeType;
- this.emitDelete = emitDelete;
}
@Override
public RecordsWithSplitIds<HoodieRecordWithPosition<RowData>>
read(HoodieSourceSplit split) {
final String splitId = split.splitId();
- HoodieTableMetaClient metaClient =
StreamerUtil.metaClientForReader(configuration, getHadoopConf());
+ HoodieTableMetaClient metaClient = StreamerUtil.metaClientForReader(conf,
getHadoopConf());
try {
+ if (fileGroupReader != null) {
+ fileGroupReader.close();
+ }
this.fileGroupReader = createFileGroupReader(split, metaClient);
- final ClosableIterator<RowData> recordIterator =
fileGroupReader.getClosableIterator();
+ ClosableIterator<RowData> recordIterator =
fileGroupReader.getClosableIterator();
+ if (limit > 0) {
+ recordIterator = limitIterator(recordIterator, limit);
Review Comment:
It is a nice catch. Yes, the limit should be applied in subtask level rather
than split level.
--
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]