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

 ##########
 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:
   @rdblue updated to `expireOlderThan` and `retainLast` work with one another. 
Whichever sets oldest `expireOlderThan` takes precedence. 

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

Reply via email to