aokolnychyi commented on a change in pull request #631: Add mechanism to expire
old metadata versions
URL: https://github.com/apache/incubator-iceberg/pull/631#discussion_r347045945
##########
File path:
core/src/main/java/org/apache/iceberg/hadoop/HadoopTableOperations.java
##########
@@ -285,4 +290,31 @@ private RuntimeException tryDelete(Path path) {
protected FileSystem getFileSystem(Path path, Configuration hadoopConf) {
return Util.getFs(path, hadoopConf);
}
+
+ /**
+ * 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
+ */
+ private 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);
+
+ Set<TableMetadata.MetadataLogEntry> removedPreviousMetadataFiles =
Sets.newHashSet(base.previousFiles());
+ removedPreviousMetadataFiles.removeAll(metadata.previousFiles());
+
+ if (deleteAfterCommit) {
Review comment:
nit: I would probably add `!removedPreviousMetadataFiles.isEmpty()` to the
condition, but it is minor.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]