technicolorbeat commented on code in PR #2186:
URL: https://github.com/apache/iceberg-go/pull/2186#discussion_r4275203249


##########
table/deferred_snapshots.go:
##########
@@ -41,6 +43,69 @@ type deferredSnapshotState struct {
        err       error
 }
 
+// deferredSnapshotOverlay records mutations over an immutable deferred
+// snapshot state. Builders own a mutable overlay and clone it when producing
+// metadata so built metadata cannot observe subsequent builder changes.
+type deferredSnapshotOverlay struct {
+       additions []Snapshot
+       removed   map[int64]struct{}
+}
+
+func (o *deferredSnapshotOverlay) clone() *deferredSnapshotOverlay {
+       if o == nil {
+               return nil
+       }
+
+       return &deferredSnapshotOverlay{
+               additions: cloneSnapshots(o.additions),
+               removed:   maps.Clone(o.removed),
+       }
+}
+
+func (o *deferredSnapshotOverlay) isRemoved(id int64) bool {
+       if o == nil {
+               return false
+       }
+
+       _, ok := o.removed[id]
+
+       return ok
+}
+
+func (o *deferredSnapshotOverlay) add(snapshot Snapshot) {
+       o.additions = append(o.additions, snapshot)
+}
+
+func (o *deferredSnapshotOverlay) remove(ids map[int64]struct{}) {
+       if o.removed == nil {
+               o.removed = make(map[int64]struct{}, len(ids))
+       }
+       for id := range ids {
+               o.removed[id] = struct{}{}

Review Comment:
   Resolving commit: 
[caecd53](https://github.com/apache/iceberg-go/commit/caecd53f2a6642090eba8a101191ed2b8a2aafa2).



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