kbendick commented on code in PR #4651:
URL: https://github.com/apache/iceberg/pull/4651#discussion_r860192037
##########
core/src/main/java/org/apache/iceberg/TableOperations.java:
##########
@@ -120,4 +124,31 @@ default long newSnapshotId() {
return (mostSignificantBits ^ leastSignificantBits) & Long.MAX_VALUE;
}
+ /**
+ * Deletes the oldest metadata files if {@link
TableProperties#METADATA_DELETE_AFTER_COMMIT_ENABLED} is true.
+ *
+ * @param base table metadata on which previous versions were based
+ * @param metadata new table metadata with updated previous versions
+ */
+ default void deleteRemovedMetadataFiles(TableMetadata base, TableMetadata
metadata) {
+ if (base == null) {
+ return;
+ }
+
+ boolean deleteAfterCommit = metadata.propertyAsBoolean(
+ TableProperties.METADATA_DELETE_AFTER_COMMIT_ENABLED,
+ TableProperties.METADATA_DELETE_AFTER_COMMIT_ENABLED_DEFAULT);
+
+ if (deleteAfterCommit) {
+ Set<TableMetadata.MetadataLogEntry> removedPreviousMetadataFiles =
Sets.newHashSet(base.previousFiles());
+ removedPreviousMetadataFiles.removeAll(metadata.previousFiles());
+ Tasks.foreach(removedPreviousMetadataFiles)
+ .noRetry().suppressFailureWhenFinished()
+ .onFailure((previousMetadataFile, exc) ->
+ LoggerFactory.getLogger(TableOperations.class).warn("Delete
failed for previous metadata file: {}",
Review Comment:
Nit: I don't think this move is necessary, but if it does happen, we
shouldn't be instantiating the logger every time we call the log function.
--
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]