Repository navigation
fix(table): find min seq correctly from manifest list - #693
Conversation
| var n int64 | ||
| found := false | ||
| for _, m := range manifests { |
There was a problem hiding this comment.
why is the found variable needed? what test scenario is different with this change from what it was before?
There was a problem hiding this comment.
It could cause wrong delete manifests to apply because old code always returns zero due to wrong initial condition. found enables setting it unconditionally at first.
There was a problem hiding this comment.
The zero value of int64 is still 0, so this doesn't functionally change anything. You'd have to initialize n to -1 or something that would designate an invalid seq number
There was a problem hiding this comment.
n is set to first value in the first iteration because found is false then we keep applying min. Previously, it was set to zero and zero is already minimum value so it doesn't change with manifest version where it should have been.
There was a problem hiding this comment.
Ah, I see what you mean. I feel like we could initialize n to INT_MAX to fix it and simplify, right? Something like...
n := math.MaxInt64
for _, m := range manifests {
if m.ManifestContent() == iceberg.ManifestContentData {
n = min(n, m.MinSequenceNum())
}
}
if n == math.MaxInt64 {
n = 0
}
return nI find that simpler to read than having the found check. Make sense?
There was a problem hiding this comment.
I didn't want to import math at first but yes, it works as well. Updated so
Signed-off-by: ferhat elmas <[email protected]>
ec6ea0c to
0cf2c4c
Compare
No description provided.