felixYyu opened a new issue #4368:
URL: https://github.com/apache/iceberg/issues/4368
in BaseDeleteOrphanFilesSparkAction to
buildValidMetadataFileDF->BaseSparkAction.buildOtherMetadataFileDF->ReachableFileUtil.metadataFileLocations,
the first existent previous metadata need FIFO or LIFO?
```
public static Set<String> metadataFileLocations(Table table, boolean
recursive) {
Set<String> metadataFileLocations = Sets.newHashSet();
TableOperations ops = ((HasTableOperations) table).operations();
TableMetadata tableMetadata = ops.current();
metadataFileLocations.add(tableMetadata.metadataFileLocation());
metadataFileLocations(tableMetadata, metadataFileLocations, ops.io(),
recursive);
return metadataFileLocations;
}
private static void metadataFileLocations(TableMetadata metadata,
Set<String> metadataFileLocations,
FileIO io, boolean recursive) {
List<MetadataLogEntry> metadataLogEntries = metadata.previousFiles();
if (metadataLogEntries.size() > 0) {
for (MetadataLogEntry metadataLogEntry : metadataLogEntries) {
metadataFileLocations.add(metadataLogEntry.file());
}
if (recursive) {
TableMetadata previousMetadata =
findFirstExistentPreviousMetadata(metadataLogEntries, io);
if (previousMetadata != null) {
metadataFileLocations(previousMetadata, metadataFileLocations, io,
recursive);
}
}
}
}
private static TableMetadata
findFirstExistentPreviousMetadata(List<MetadataLogEntry> metadataLogEntries,
FileIO io) {
TableMetadata metadata = null;
for (MetadataLogEntry metadataLogEntry : metadataLogEntries) {
try {
metadata = TableMetadataParser.read(io, metadataLogEntry.file());
break;
} catch (Exception e) {
LOG.error("Failed to load {}", metadataLogEntry, e);
}
}
return metadata;
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]