YuweiXiao commented on code in PR #6680:
URL: https://github.com/apache/hudi/pull/6680#discussion_r979367133
##########
hudi-common/src/main/java/org/apache/hudi/BaseHoodieTableFileIndex.java:
##########
@@ -221,60 +329,46 @@ protected HoodieTimeline getActiveTimeline() {
}
/**
- * Load all partition paths and it's files under the query table path.
+ * Load partition paths and it's files under the query table path.
*/
- private Map<PartitionPath, FileStatus[]> loadPartitionPathFiles() {
- // List files in all partition paths
- List<PartitionPath> pathToFetch = new ArrayList<>();
- Map<PartitionPath, FileStatus[]> cachedPartitionToFiles = new HashMap<>();
-
- // Fetch from the FileStatusCache
- List<PartitionPath> partitionPaths = getAllQueryPartitionPaths();
- partitionPaths.forEach(partitionPath -> {
- Option<FileStatus[]> filesInPartition =
fileStatusCache.get(partitionPath.fullPartitionPath(basePath));
- if (filesInPartition.isPresent()) {
- cachedPartitionToFiles.put(partitionPath, filesInPartition.get());
- } else {
- pathToFetch.add(partitionPath);
- }
- });
-
- Map<PartitionPath, FileStatus[]> fetchedPartitionToFiles;
-
- if (pathToFetch.isEmpty()) {
- fetchedPartitionToFiles = Collections.emptyMap();
- } else {
- Map<String, PartitionPath> fullPartitionPathsMapToFetch =
pathToFetch.stream()
- .collect(Collectors.toMap(
- partitionPath ->
partitionPath.fullPartitionPath(basePath).toString(),
- Function.identity())
- );
-
- fetchedPartitionToFiles =
-
getAllFilesInPartitionsUnchecked(fullPartitionPathsMapToFetch.keySet())
- .entrySet()
- .stream()
- .collect(Collectors.toMap(e ->
fullPartitionPathsMapToFetch.get(e.getKey()), e -> e.getValue()));
-
+ private FileStatus[] loadPartitionPathFiles(PartitionPath partition) {
+ // Try fetch from the FileStatusCache first
+ Option<FileStatus[]> files =
fileStatusCache.get(partition.fullPartitionPath(basePath));
+ if (files.isPresent()) {
+ return files.get();
}
- // Update the fileStatusCache
- fetchedPartitionToFiles.forEach((partitionPath, filesInPartition) -> {
- fileStatusCache.put(partitionPath.fullPartitionPath(basePath),
filesInPartition);
- });
+ try {
+ Path path = partition.fullPartitionPath(basePath);
+ FileStatus[] fetchedFiles = tableMetadata.getAllFilesInPartition(path);
- return CollectionUtils.combine(cachedPartitionToFiles,
fetchedPartitionToFiles);
+ // Update the fileStatusCache
+ fileStatusCache.put(partition.fullPartitionPath(basePath), fetchedFiles);
+ return fetchedFiles;
+ } catch (IOException e) {
+ throw new HoodieIOException("Failed to list partition path (" +
partition + ") for a table", e);
+ }
}
private void doRefresh() {
+ doRefresh(false);
+ }
+
+ private void doRefresh(boolean initMetadataOnly) {
Review Comment:
Done.
--
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]