amogh-jahagirdar commented on a change in pull request #4071:
URL: https://github.com/apache/iceberg/pull/4071#discussion_r837035716
##########
File path: core/src/main/java/org/apache/iceberg/MetadataUpdate.java
##########
@@ -223,31 +225,117 @@ public String name() {
@Override
public void applyTo(TableMetadata.Builder metadataBuilder) {
- // TODO: this should be generalized when tagging is supported
- metadataBuilder.removeBranch(name);
+ SnapshotRef ref = metadataBuilder.ref(name);
+ ValidationException.check(ref != null, "Ref %s not found", name);
+ if (ref.isBranch()) {
+ metadataBuilder.removeBranch(name);
+ } else {
+ metadataBuilder.removeTag(name);
+ }
}
}
class SetSnapshotRef implements MetadataUpdate {
- private final String name;
- private final long snapshotId;
-
- public SetSnapshotRef(String name, long snapshotId) {
- this.name = name;
+ private final String ref;
+ private final Long snapshotId;
+ private final SnapshotRefType type;
+ private final Integer minSnapshotsToKeep;
+ private final Long maxSnapshotAgeMs;
+ private final Long maxRefAgeMs;
+
+ public SetSnapshotRef(String ref, Long snapshotId, SnapshotRefType type,
Integer minSnapshotsToKeep,
+ Long maxSnapshotAgeMs, Long maxRefAgeMs) {
+ this.ref = ref;
this.snapshotId = snapshotId;
+ this.type = type;
+ this.minSnapshotsToKeep = minSnapshotsToKeep;
+ this.maxSnapshotAgeMs = maxSnapshotAgeMs;
+ this.maxRefAgeMs = maxRefAgeMs;
}
- public String name() {
- return name;
+ @SuppressWarnings("checkstyle:HiddenField")
+ public static class Builder {
Review comment:
I'm hesitant on this since it feels a little overengineered. But having
a builder for the Metadata update seemed like the best way to iteratively
update the produced change in the Builder.SetBranch itself as we determine
what's different between branches, and preserve immutability. We could also
just add setters on the update but that seemed to go against the whole
principal? @rdblue thoughts
--
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]