You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2019/09/30 17:10:28 UTC

[GitHub] [incubator-iceberg] rdblue commented on a change in pull request #497: Support retaining last N snapshots

rdblue commented on a change in pull request #497: Support retaining last N snapshots
URL: https://github.com/apache/incubator-iceberg/pull/497#discussion_r329689375
 
 

 ##########
 File path: core/src/main/java/org/apache/iceberg/RemoveSnapshots.java
 ##########
 @@ -82,6 +83,18 @@ public ExpireSnapshots expireOlderThan(long timestampMillis) {
     return this;
   }
 
+  @Override
+  public ExpireSnapshots retainLast(int numSnapshots) {
+    Preconditions.checkArgument(1 < numSnapshots,
+            "Number of snapshots to retain must be at least 1, cannot be: %s", numSnapshots);
+    LOG.info("Retaining last {} snapshots and expiring older snapshots", numSnapshots);
+    Snapshot nthSnapshot = findNthSnapshot(numSnapshots);
+    if (nthSnapshot != null) {
+      expireOlderThan(nthSnapshot.timestampMillis());
 
 Review comment:
   This isn't the behavior I would expect from `retainLast`. I would expect to be able to combine this (`retainLast(20)`) with a call to `expireOlderThan(T)`, where snapshots older than T are expired, but at least 20 snapshots are kept. Instead, these two calls would conflict and one would clobber the other.
   
   I would prefer to go with the behavior I described above, where the two configurations work with one another. If one configuration overwrites the other, then we would need to track which one is set and throw an exception if both are called to let the caller know that the API was misused.
   
   I think it's better to avoid a runtime exception by documenting the behavior when the two are used together.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org