laskoviymishka commented on code in PR #1022:
URL: https://github.com/apache/iceberg-go/pull/1022#discussion_r3196136423
##########
table/snapshot_producers.go:
##########
@@ -54,6 +54,8 @@ type producerImpl interface {
// producers that are safe against concurrent appends (fast-append
// and merge-append).
validate(cc *conflictContext) error
+
+ needsValidation() bool
Review Comment:
Worth a one-line doc on the contract here? The neighbour `validate` has a
7-line block (lines 50-56), and `needsValidation` is the gate that decides
whether `validate` even runs — defining "return false iff validate is
unconditionally a no-op" pins the invariant at the declaration. Without it,
someone could add real work to a producer's `validate()` later without flipping
the predicate and silently bypass the check.
##########
table/snapshot_producers.go:
##########
@@ -897,7 +903,7 @@ func (sp *snapshotProducer) commit(ctx context.Context) (_
[]Update, _ []Require
// pay only the no-op-closure cost. Nil producerImpl is possible
// only in unit tests that exercise commit() directly on a bare
// snapshotProducer; guard to keep those tests green.
- if impl := sp.producerImpl; impl != nil {
+ if impl := sp.producerImpl; impl != nil && impl.needsValidation() {
Review Comment:
Comment block just above is now stale — it still says fast/merge-append `pay
only the no-op-closure cost`, but with the new gate they pay nothing. I'd
freshen the rationale while we're here, e.g. "Producers that are commutative
against concurrent appends (fast-append, merge-append) opt out via
`needsValidation() == false` and skip registration entirely. The nil guard
remains for unit tests that drive `commit()` on a bare `snapshotProducer`."
##########
table/snapshot_producers.go:
##########
@@ -111,6 +113,8 @@ func (fa *fastAppendFiles) validate(_ *conflictContext)
error {
return nil
}
+func (fa *fastAppendFiles) needsValidation() bool { return false }
Review Comment:
Tiny robustness ask while we're here: I'd consider adding an explicit `func
(m *mergeAppendFiles) needsValidation() bool { return false }` next to the
`mergeAppendFiles` declaration so the choice is local to that type rather than
inherited via Go method promotion from the embedded `fastAppendFiles`. Right
now nothing at the `mergeAppendFiles` site signals the policy, and a future
producer copy-pasting the embed pattern would silently inherit `false` with no
compiler nudge. wdyt?
--
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]