jackye1995 commented on code in PR #5459:
URL: https://github.com/apache/iceberg/pull/5459#discussion_r939739421
##########
core/src/main/java/org/apache/iceberg/CatalogUtil.java:
##########
@@ -102,45 +106,53 @@ public static void dropTableData(FileIO io, TableMetadata
metadata) {
deleteFiles(io, manifestsToDelete);
}
- Tasks.foreach(Iterables.transform(manifestsToDelete, ManifestFile::path))
- .executeWith(ThreadPools.getWorkerPool())
- .noRetry()
- .suppressFailureWhenFinished()
- .onFailure((manifest, exc) -> LOG.warn("Delete failed for manifest:
{}", manifest, exc))
- .run(io::deleteFile);
-
- Tasks.foreach(manifestListsToDelete)
- .executeWith(ThreadPools.getWorkerPool())
- .noRetry()
- .suppressFailureWhenFinished()
- .onFailure((list, exc) -> LOG.warn("Delete failed for manifest list:
{}", list, exc))
- .run(io::deleteFile);
-
- Tasks.foreach(
- Iterables.transform(metadata.previousFiles(),
TableMetadata.MetadataLogEntry::file))
- .executeWith(ThreadPools.getWorkerPool())
- .noRetry()
- .suppressFailureWhenFinished()
- .onFailure(
- (metadataFile, exc) ->
- LOG.warn("Delete failed for previous metadata file: {}",
metadataFile, exc))
- .run(io::deleteFile);
-
- Tasks.foreach(metadata.metadataFileLocation())
- .noRetry()
- .suppressFailureWhenFinished()
- .onFailure(
- (metadataFile, exc) ->
- LOG.warn("Delete failed for metadata file: {}", metadataFile,
exc))
- .run(io::deleteFile);
+ if (io instanceof SupportsBulkOperations) {
+ SupportsBulkOperations bulkFileIO = (SupportsBulkOperations) io;
+ bulkFileIO.deleteFiles(Iterables.transform(manifestsToDelete,
ManifestFile::path));
+ bulkFileIO.deleteFiles(manifestListsToDelete);
+ bulkFileIO.deleteFiles(
+ Iterables.transform(metadata.previousFiles(),
TableMetadata.MetadataLogEntry::file));
+
bulkFileIO.deleteFiles(ImmutableList.of(metadata.metadataFileLocation()));
+ } else {
+ Tasks.foreach(Iterables.transform(manifestsToDelete, ManifestFile::path))
+ .executeWith(ThreadPools.getWorkerPool())
+ .noRetry()
+ .suppressFailureWhenFinished()
+ .onFailure((manifest, exc) -> LOG.warn("Delete failed for manifest:
{}", manifest, exc))
+ .run(io::deleteFile);
+
+ Tasks.foreach(manifestListsToDelete)
+ .executeWith(ThreadPools.getWorkerPool())
+ .noRetry()
+ .suppressFailureWhenFinished()
+ .onFailure((list, exc) -> LOG.warn("Delete failed for manifest list:
{}", list, exc))
+ .run(io::deleteFile);
+
+ Tasks.foreach(
+ Iterables.transform(metadata.previousFiles(),
TableMetadata.MetadataLogEntry::file))
+ .executeWith(ThreadPools.getWorkerPool())
+ .noRetry()
+ .suppressFailureWhenFinished()
+ .onFailure(
+ (metadataFile, exc) ->
+ LOG.warn("Delete failed for previous metadata file: {}",
metadataFile, exc))
+ .run(io::deleteFile);
+
+ Tasks.foreach(metadata.metadataFileLocation())
+ .noRetry()
+ .suppressFailureWhenFinished()
+ .onFailure(
+ (metadataFile, exc) ->
+ LOG.warn("Delete failed for metadata file: {}",
metadataFile, exc))
+ .run(io::deleteFile);
+ }
}
@SuppressWarnings("DangerousStringInternUsage")
private static void deleteFiles(FileIO io, Set<ManifestFile> allManifests) {
// keep track of deleted files in a map that can be cleaned up when memory
runs low
Map<String, Boolean> deletedFiles =
new
MapMaker().concurrencyLevel(ThreadPools.WORKER_THREAD_POOL_SIZE).weakKeys().makeMap();
-
Review Comment:
nit: avoid unnecessary newline change
--
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]