rdblue commented on code in PR #4578:
URL: https://github.com/apache/iceberg/pull/4578#discussion_r863331581


##########
core/src/main/java/org/apache/iceberg/RemoveSnapshots.java:
##########
@@ -163,21 +188,100 @@ private TableMetadata internalApply() {
     this.base = ops.refresh();
 
     Set<Long> idsToRetain = Sets.newHashSet();
-    List<Long> ancestorIds = SnapshotUtil.ancestorIds(base.currentSnapshot(), 
base::snapshot);
-    if (minNumSnapshots >= ancestorIds.size()) {
+    // Identify refs that should be removed
+    Set<String> expiredRefs = computeExpiredRefs(base.refs());
+    Set<Long> idsOfRetainedRefs = base.refs().entrySet().stream()
+        .filter(ref -> !expiredRefs.contains(ref.getKey()))
+        .map(refEntry -> refEntry.getValue().snapshotId())
+        .collect(Collectors.toSet());
+
+    for (Long idToRemove : idsToRemove) {

Review Comment:
   Try to use primitives where possible. Here, you know that each ref had a 
non-null snapshot ID, so you know all of these are going to be non-null.



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