jackye1995 commented on a change in pull request #3104: URL: https://github.com/apache/iceberg/pull/3104#discussion_r743119758
########## File path: api/src/main/java/org/apache/iceberg/SnapshotReference.java ########## @@ -0,0 +1,152 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iceberg; + +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import org.apache.iceberg.exceptions.ValidationException; + +/** + * User-defined information of a named snapshot + */ +public class SnapshotReference { + + private final long snapshotId; + private final String name; + private final SnapshotReferenceType type; + private final Integer minSnapshotsToKeep; + private final long maxSnapshotAgeMs; + + private SnapshotReference( + long snapshotId, + String name, + SnapshotReferenceType type, + Integer minSnapshotsToKeep, + long maxSnapshotAgeMs) { + this.snapshotId = snapshotId; + this.name = name; + this.type = type; + this.minSnapshotsToKeep = minSnapshotsToKeep; + this.maxSnapshotAgeMs = maxSnapshotAgeMs; + } + + public long snapshotId() { + return snapshotId; + } + + public String snapshotName() { + return name; + } + + public SnapshotReferenceType type() { + return type; + } + + /** + * Returns the minimum number of snapshots to keep for a BRANCH, or null for a TAG + */ + public Integer minSnapshotsToKeep() { + return minSnapshotsToKeep; + } + + public long maxSnapshotAgeMs() { + return maxSnapshotAgeMs; + } + + public static Builder builderFor(long snapshotId, String name, SnapshotReferenceType type) { + return new Builder(snapshotId, name, type); + } + + public static class Builder { + + private final Long snapshotId; + private final String name; + private final SnapshotReferenceType type; + private Integer minSnapshotsToKeep; + private Long maxSnapshotAgeMs; + + Builder(long snapshotId, String name, SnapshotReferenceType type) { + ValidationException.check(snapshotId > 0, "Snapshot ID must be greater than 0"); + ValidationException.check(name != null, "Snapshot reference name must not be null"); + this.snapshotId = snapshotId; + this.name = name; + this.type = type; + } + + public Builder withMinSnapshotsToKeep(Integer value) { Review comment: will be used once we added it to spec -- 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]
