yathindranath commented on a change in pull request #497: Support retaining
last N snapshots
URL: https://github.com/apache/incubator-iceberg/pull/497#discussion_r332683939
##########
File path: core/src/main/java/org/apache/iceberg/RemoveSnapshots.java
##########
@@ -77,8 +79,34 @@ public ExpireSnapshots expireSnapshotId(long
expireSnapshotId) {
@Override
public ExpireSnapshots expireOlderThan(long timestampMillis) {
- LOG.info("Expiring snapshots older than: {} ({})", new
Date(timestampMillis), timestampMillis);
- this.expireOlderThan = timestampMillis;
+ updateExpireOlderThan(timestampMillis, true);
+ return this;
+ }
+
+ private boolean updateExpireOlderThan(long timestampMillis, boolean
fromExpireOlderThan) {
+ if (expireOlderThan == null ||
+ expireOlderThan > timestampMillis ||
+ this.isExpireOlderThanSet == fromExpireOlderThan) {
+ LOG.info("Expiring snapshots older than: {} ({})", new
Date(timestampMillis), timestampMillis);
+ this.expireOlderThan = timestampMillis;
+ this.isExpireOlderThanSet = fromExpireOlderThan;
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public ExpireSnapshots retainLast(int numSnapshots) {
Review comment:
@rdblue interesting behavior.
Your earlier comment _"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."_ .
I think the behavior you mentioned in your earlier comment is more
straightforward. We could discuss more on the behavior of `retainLast(n)` and
how to find the N snapshots.
Another way to expire snapshots is `expireOlderThanSnapshot(snapshotId)`.
----------------------------------------------------------------
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]