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


##########
table/snapshot_producers.go:
##########
@@ -86,8 +86,14 @@ func (fa *fastAppendFiles) existingManifests() 
([]iceberg.ManifestFile, error) {
                        return nil, err
                }
 
+               // This provides a constant-time (O(1)) search in a loop.
+               previousSnapshotList := make(map[int64]struct{}, 
len(fa.base.txn.meta.snapshotList))
+               for _, sn := range fa.base.txn.meta.snapshotList {
+                       previousSnapshotList[sn.SnapshotID] = struct{}{}
+               }
+
                for _, m := range manifests {
-                       if m.HasAddedFiles() || m.HasExistingFiles() || 
m.SnapshotID() == fa.base.snapshotID {
+                       if _, ok := previousSnapshotList[m.SnapshotID()]; 
m.HasAddedFiles() || m.HasExistingFiles() || ok {

Review Comment:
   I'm confused, if we're saying that the existing manifests *can't* contain 
the current snapshot_id shouldn't this use `!ok`?
   
   Why are we searching the previous snapshot list? Couldn't we just remove 
this check entirely and just do `if m.HasAddedFiles() || m.HasExistingFiles() 
{` ?



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