rdblue commented on a change in pull request #695: [WIP] Cherrypick snapshot 
feature
URL: https://github.com/apache/incubator-iceberg/pull/695#discussion_r368055946
 
 

 ##########
 File path: core/src/main/java/org/apache/iceberg/util/SnapshotUtil.java
 ##########
 @@ -55,4 +56,28 @@ private SnapshotUtil() {
     }
     return ancestorIds;
   }
+
+  public static boolean isCurrentAncestor(TableMetadata tableMeta, long 
snapshotId) {
+    List<Long> currentAncestors = 
SnapshotUtil.ancestorIds(tableMeta.currentSnapshot(), tableMeta::snapshot);
+    return currentAncestors.contains(snapshotId);
+  }
+
+  /**
+   * Return the latest snapshot whose timestamp is before the provided 
timestamp.
+   * @param tableMeta TableMetadata representing the table state on which the 
snapshot is being looked up
+   * @param timestampMillis lookup snapshots before this timestamp
+   * @return
+   */
+  public static Snapshot findLatestSnapshotOlderThan(TableMetadata tableMeta, 
long timestampMillis) {
+    long snapshotTimestamp = 0;
+    Snapshot result = null;
+    for (Snapshot snapshot : tableMeta.snapshots()) {
 
 Review comment:
   Should this traverse `ancestorIds` instead? The reason is that `rollbackTo` 
checks that the target snapshot is an ancestor of the current table state to 
verify it is a rollback and not a fast-forward or a complete change. Since this 
is called only by `rollbackToTime`, I think it makes sense to have the same 
requirement.
   
   If you agree, I'd have this traverse the ancestor IDs and rename it to 
`findLatestAncestorOlderThan`.

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