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


##########
table/updates.go:
##########
@@ -534,9 +535,42 @@ func (u *removeSnapshotsUpdate) PostCommit(ctx 
context.Context, preTable *Table,
                delete(filesToDelete, psf.StatisticsPath)
        }
 
-       var res error
+       if len(filesToDelete) == 0 {
+               return nil
+       }
 
+       paths := make([]string, 0, len(filesToDelete))
        for f := range filesToDelete {
+               paths = append(paths, f)
+       }
+
+       // Try bulk delete first; on failure fall through to per-file delete.
+       if bulk, ok := prefs.(io.BulkRemovableIO); ok {
+               deleted, err := bulk.DeleteFiles(ctx, paths)
+               if err == nil {
+                       return nil
+               }
+
+               // Remove successfully deleted files so the fallback loop
+               // only retries what the bulk call missed.
+               deletedSet := make(map[string]struct{}, len(deleted))
+               for _, d := range deleted {
+                       deletedSet[d] = struct{}{}
+               }
+
+               remaining := paths[:0]
+               for _, p := range paths {
+                       if _, ok := deletedSet[p]; !ok {
+                               remaining = append(remaining, p)
+                       }
+               }
+
+               paths = remaining

Review Comment:
   ```suggestion
           paths = slices.DeleteFunc(paths, func(s string) bool {
               _, ok := deletedSet[s]
               return ok
           })
   ```



##########
table/updates.go:
##########
@@ -534,9 +535,42 @@ func (u *removeSnapshotsUpdate) PostCommit(ctx 
context.Context, preTable *Table,
                delete(filesToDelete, psf.StatisticsPath)
        }
 
-       var res error
+       if len(filesToDelete) == 0 {
+               return nil
+       }
 
+       paths := make([]string, 0, len(filesToDelete))
        for f := range filesToDelete {
+               paths = append(paths, f)
+       }

Review Comment:
   ```suggestion
        paths := maps.Keys(filesToDelete)
   ```
   



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