danny0405 commented on code in PR #13060: URL: https://github.com/apache/hudi/pull/13060#discussion_r2029632471
########## hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/source/FileIndex.java: ########## @@ -157,28 +157,34 @@ public List<StoragePathInfo> getFilesInPartitions() { if (partitions.length < 1) { return Collections.emptyList(); } - List<StoragePathInfo> allFiles = FSUtils.getFilesInPartitions( - new HoodieFlinkEngineContext(hadoopConf), - new HoodieHadoopStorage(path, HadoopFSUtils.getStorageConf(hadoopConf)), metadataConfig, path.toString(), partitions) - .values().stream() - .flatMap(Collection::stream) - .collect(Collectors.toList()); + Map<String, List<StoragePathInfo>> partition2Files = FSUtils.getFilesInPartitions( + new HoodieFlinkEngineContext(hadoopConf), + new HoodieHadoopStorage(path, HadoopFSUtils.getStorageConf(hadoopConf)), metadataConfig, path.toString(), partitions); + + List<StoragePathInfo> allFiles; + // bucket pruning + if (this.partitionBucketIdFunc != null) { + allFiles = partition2Files.entrySet().stream().flatMap(entry -> { + String partitionPath = entry.getKey(); + int bucketId = partitionBucketIdFunc.apply(partitionPath); + String bucketIdStr = BucketIdentifier.bucketIdStr(bucketId); + List<StoragePathInfo> filesInPartition = entry.getValue(); + return filesInPartition.stream().filter(fileInfo -> fileInfo.getPath().getName().contains(bucketIdStr)); + }).collect(Collectors.toList()); + } else { + allFiles = FSUtils.getFilesInPartitions( Review Comment: should use `partition2Files` to avoid redundant files fetching. -- 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