jackye1995 commented on a change in pull request #3612:
URL: https://github.com/apache/iceberg/pull/3612#discussion_r758057223



##########
File path: api/src/main/java/org/apache/iceberg/UpdateSnapshotReference.java
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.Map;
+
+/**
+ * API for updating snapshot reference.
+ * <p>
+ * Apply returns the updated snapshot reference as a {@link SnapshotReference} 
for validation.

Review comment:
       it is unclear to me what you mean by this, I think this sentence is not 
needed because the return type is self-explanatory.

##########
File path: api/src/main/java/org/apache/iceberg/UpdateSnapshotReference.java
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.Map;
+
+/**
+ * API for updating snapshot reference.
+ * <p>
+ * Apply returns the updated snapshot reference as a {@link SnapshotReference} 
for validation.
+ * <p>
+ * When committing, these changes will be applied to the current table 
metadata. Commit conflicts
+ * will be resolved by applying the pending changes to the new table metadata.
+ */
+public interface UpdateSnapshotReference extends PendingUpdate<Map<String, 
SnapshotReference>> {
+
+  /**
+   * remove snapshotReference.
+   *
+   * @param name name of snapshot reference
+   * @return this
+   * @throws IllegalArgumentException If there is no such snapshot reference 
named name
+   */
+  UpdateSnapshotReference removeReference(String name);

Review comment:
       nit: prefer to use `ref` over `reference`, such as `removeRef`

##########
File path: api/src/main/java/org/apache/iceberg/UpdateSnapshotReference.java
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.Map;
+
+/**
+ * API for updating snapshot reference.
+ * <p>
+ * Apply returns the updated snapshot reference as a {@link SnapshotReference} 
for validation.
+ * <p>
+ * When committing, these changes will be applied to the current table 
metadata. Commit conflicts
+ * will be resolved by applying the pending changes to the new table metadata.
+ */
+public interface UpdateSnapshotReference extends PendingUpdate<Map<String, 
SnapshotReference>> {
+
+  /**
+   * remove snapshotReference.
+   *
+   * @param name name of snapshot reference
+   * @return this
+   * @throws IllegalArgumentException If there is no such snapshot reference 
named name
+   */
+  UpdateSnapshotReference removeReference(String name);
+
+  /**
+   * Update minSnapshotsToKeep of snapshotReference what will be search by 
referenceName and snapshotReferenceType.
+   *
+   * @param ageMs       new maxSnapshotAgeMs for snapshot reference. If null 
will not update.
+   * @param numToKeep   new minSnapshotsToKeep for snapshot reference. If null 
will not update.
+   * @param name        name of snapshot reference what will be update
+   * @return this
+   */
+
+  UpdateSnapshotReference setBranchRetention(String name, Long ageMs, Integer 
numToKeep);

Review comment:
       I think we should use primitive values so that people must specify a 
value. Having a method call like `setBranchRetention("test", null, null)` is 
unfriendly to readers of the code.
   
   But I understand we want to have the flexibility for users to use defaults. 
We can potentially introduce 2 different methods for these two settings 
separately, like `setBranchSnapshotLifetime(String name, long ageMs)` and 
`setMinSnapshotsInBranch(String name, int num)`, but maybe its a bit overkill. 

##########
File path: api/src/main/java/org/apache/iceberg/UpdateSnapshotReference.java
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.Map;
+
+/**
+ * API for updating snapshot reference.
+ * <p>
+ * Apply returns the updated snapshot reference as a {@link SnapshotReference} 
for validation.
+ * <p>
+ * When committing, these changes will be applied to the current table 
metadata. Commit conflicts
+ * will be resolved by applying the pending changes to the new table metadata.
+ */
+public interface UpdateSnapshotReference extends PendingUpdate<Map<String, 
SnapshotReference>> {
+
+  /**
+   * remove snapshotReference.
+   *
+   * @param name name of snapshot reference
+   * @return this
+   * @throws IllegalArgumentException If there is no such snapshot reference 
named name
+   */
+  UpdateSnapshotReference removeReference(String name);
+
+  /**
+   * Update minSnapshotsToKeep of snapshotReference what will be search by 
referenceName and snapshotReferenceType.
+   *
+   * @param ageMs       new maxSnapshotAgeMs for snapshot reference. If null 
will not update.
+   * @param numToKeep   new minSnapshotsToKeep for snapshot reference. If null 
will not update.
+   * @param name        name of snapshot reference what will be update
+   * @return this
+   */
+
+  UpdateSnapshotReference setBranchRetention(String name, Long ageMs, Integer 
numToKeep);
+
+  /**
+   * Update minSnapshotsToKeep of snapshotReference what will be search by 
referenceName and snapshotReferenceType.
+   *
+   * @param maxRefAgeMs new maxRefAgeMs for snapshot reference. If null will 
not update.
+   * @param name        name of snapshot reference what will be update
+   * @return this
+   */
+

Review comment:
       nit: extra blank line

##########
File path: api/src/main/java/org/apache/iceberg/UpdateSnapshotReference.java
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.Map;
+
+/**
+ * API for updating snapshot reference.
+ * <p>
+ * Apply returns the updated snapshot reference as a {@link SnapshotReference} 
for validation.
+ * <p>
+ * When committing, these changes will be applied to the current table 
metadata. Commit conflicts

Review comment:
       Consider the situation that user A sets a retention policy for branch, 
and B sets retention policy for the same branch. Then both commits would 
succeed and one of the commit would be clobbered. 
   
   So I think the safest way to go is to not resolve commit conflicts. If the 
metadata is no longer current, a CommitFailedException should be thrown.

##########
File path: api/src/main/java/org/apache/iceberg/UpdateSnapshotReference.java
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.Map;
+
+/**
+ * API for updating snapshot reference.
+ * <p>
+ * Apply returns the updated snapshot reference as a {@link SnapshotReference} 
for validation.
+ * <p>
+ * When committing, these changes will be applied to the current table 
metadata. Commit conflicts
+ * will be resolved by applying the pending changes to the new table metadata.
+ */
+public interface UpdateSnapshotReference extends PendingUpdate<Map<String, 
SnapshotReference>> {
+
+  /**
+   * remove snapshotReference.
+   *
+   * @param name name of snapshot reference
+   * @return this
+   * @throws IllegalArgumentException If there is no such snapshot reference 
named name
+   */
+  UpdateSnapshotReference removeReference(String name);
+
+  /**
+   * Update minSnapshotsToKeep of snapshotReference what will be search by 
referenceName and snapshotReferenceType.
+   *
+   * @param ageMs       new maxSnapshotAgeMs for snapshot reference. If null 
will not update.
+   * @param numToKeep   new minSnapshotsToKeep for snapshot reference. If null 
will not update.
+   * @param name        name of snapshot reference what will be update
+   * @return this
+   */
+
+  UpdateSnapshotReference setBranchRetention(String name, Long ageMs, Integer 
numToKeep);
+
+  /**
+   * Update minSnapshotsToKeep of snapshotReference what will be search by 
referenceName and snapshotReferenceType.
+   *
+   * @param maxRefAgeMs new maxRefAgeMs for snapshot reference. If null will 
not update.
+   * @param name        name of snapshot reference what will be update
+   * @return this
+   */
+
+  UpdateSnapshotReference setMaxRefAgeMs(String name, Long maxRefAgeMs);
+
+  /**
+   * Update name of snapshotReference what will be search by referenceName and 
snapshotReferenceType.
+   *
+   * @param oldName old name of snapshot reference
+   * @param name    new name for snapshot reference
+   * @return this
+   */
+  UpdateSnapshotReference updateName(String oldName, String name);

Review comment:
       I think this one and `updateReference` below are not needed, what are 
their use cases? We can always remove the old one and add a new one
   

##########
File path: api/src/main/java/org/apache/iceberg/UpdateSnapshotReference.java
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.Map;
+
+/**
+ * API for updating snapshot reference.
+ * <p>
+ * Apply returns the updated snapshot reference as a {@link SnapshotReference} 
for validation.
+ * <p>
+ * When committing, these changes will be applied to the current table 
metadata. Commit conflicts
+ * will be resolved by applying the pending changes to the new table metadata.
+ */
+public interface UpdateSnapshotReference extends PendingUpdate<Map<String, 
SnapshotReference>> {
+
+  /**
+   * remove snapshotReference.
+   *
+   * @param name name of snapshot reference
+   * @return this
+   * @throws IllegalArgumentException If there is no such snapshot reference 
named name
+   */
+  UpdateSnapshotReference removeReference(String name);
+
+  /**
+   * Update minSnapshotsToKeep of snapshotReference what will be search by 
referenceName and snapshotReferenceType.

Review comment:
       nit: I think we can be more concise here, something like "Set retention 
policy of snapshots in a branch". The retention policy settings should be 
explained in `@param` part using the definition provided in the spec (#3425)




-- 
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]

Reply via email to