zeroshade commented on code in PR #1801:
URL: https://github.com/apache/iceberg-go/pull/1801#discussion_r3797464953


##########
table/metadata.go:
##########
@@ -596,20 +596,31 @@ func (b *MetadataBuilder) NextRowID() int64 {
 }
 
 func (b *MetadataBuilder) RemoveSnapshots(snapshotIds []int64, postCommit 
bool) error {
-       if b.currentSnapshotID != nil && slices.Contains(snapshotIds, 
*b.currentSnapshotID) {
-               return errors.New("current snapshot cannot be removed")
+       removedIDs := make(map[int64]struct{}, len(snapshotIds))
+       for _, snapshotID := range snapshotIds {
+               removedIDs[snapshotID] = struct{}{}
+       }
+
+       if b.currentSnapshotID != nil {
+               if _, ok := removedIDs[*b.currentSnapshotID]; ok {
+                       return errors.New("current snapshot cannot be removed")
+               }
        }
 
        b.snapshotList = slices.DeleteFunc(b.snapshotList, func(e Snapshot) 
bool {
-               return slices.Contains(snapshotIds, e.SnapshotID)
-       })
-       b.snapshotLog = slices.DeleteFunc(b.snapshotLog, func(e 
SnapshotLogEntry) bool {
-               return slices.Contains(snapshotIds, e.SnapshotID)
+               _, ok := removedIDs[e.SnapshotID]
+
+               return ok
        })

Review Comment:
   looks like you lost the snapshotLog update unless i'm missing something. I 
don't see `b.snapshotLog` getting updated anywhere anymore.



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