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


##########
bound_set_literal_view_internal_test.go:
##########
@@ -77,3 +78,86 @@ func TestVisitBoundPredicateRefDoesNotAllocate(t *testing.T) 
{
        }))
        assert.True(t, found)
 }
+
+func TestCloneBoundLiteralSetEmptyCopiesAreWritable(t *testing.T) {
+       for _, original := range []literalSet{nil, {}} {
+               cloned := cloneBoundLiteralSet(original)
+               assert.Zero(t, cloned.Len())
+               cloned.Add(NewLiteral(int32(42)))
+               assert.True(t, cloned.Contains(NewLiteral(int32(42))))
+               assert.Zero(t, original.Len())
+       }
+}
+
+func TestBoundSetPredicateLiteralsPreserveFloatingPointMembers(t *testing.T) {
+       t.Parallel()
+
+       tests := []struct {
+               name   string
+               typ    Type
+               values []Literal
+               bits   func(Literal) uint64
+       }{
+               {
+                       name: "float32",
+                       typ:  PrimitiveTypes.Float32,
+                       values: []Literal{
+                               NewLiteral(math.Float32frombits(0x7fc00001)),
+                               NewLiteral(math.Float32frombits(0x7fc00001)),
+                               NewLiteral(math.Float32frombits(0x7fc00002)),
+                               NewLiteral(float32(0)),
+                               NewLiteral(math.Float32frombits(0x80000000)),
+                               NewLiteral(float32(math.Inf(-1))),
+                               NewLiteral(float32(math.Inf(1))),
+                               NewLiteral(float32(1)),
+                       },
+                       bits: func(lit Literal) uint64 {
+                               return 
uint64(math.Float32bits(float32(lit.(Float32Literal))))
+                       },
+               },
+               {
+                       name: "float64",
+                       typ:  PrimitiveTypes.Float64,
+                       values: []Literal{
+                               
NewLiteral(math.Float64frombits(0x7ff8000000000001)),
+                               
NewLiteral(math.Float64frombits(0x7ff8000000000001)),
+                               
NewLiteral(math.Float64frombits(0x7ff8000000000002)),
+                               NewLiteral(float64(0)),
+                               
NewLiteral(math.Float64frombits(0x8000000000000000)),
+                               NewLiteral(math.Inf(-1)),
+                               NewLiteral(math.Inf(1)),
+                               NewLiteral(float64(1)),
+                       },
+                       bits: func(lit Literal) uint64 {
+                               return 
math.Float64bits(float64(lit.(Float64Literal)))
+                       },
+               },
+       }
+       for _, tt := range tests {
+               for _, op := range []Operation{OpIn, OpNotIn} {
+                       t.Run(tt.name+"/"+op.String(), func(t *testing.T) {
+                               t.Parallel()
+
+                               schema := NewSchema(1, NestedField{ID: 1, Name: 
"value", Type: tt.typ})
+                               bound, err := SetPredicate(op, 
Reference("value"), tt.values).(UnboundPredicate).Bind(schema, true)
+                               require.NoError(t, err)
+                               original := 
bound.(boundSetLiteralRef).boundSetLiteralsRef()
+                               cloned := bound.(BoundSetPredicate).Literals()
+                               require.Equal(t, 7, original.Len())
+                               require.Equal(t, original.Len(), cloned.Len())

Review Comment:
   Non-blocking: this test doesn't guard the new code. With 
`cloneBoundLiteralSet` mutated to `return lits` (no copy at all) it still 
passes, because `original` and `cloned` are then the same map. Every plausible 
way of writing the copy (range + assign, `Members()` + `Add`, `maps.Clone`) 
keeps the NaN and ±0 entries, so there's no realistic clone regression for it 
to catch. What it does pin is `original.Len() == 7`, i.e. that the set holds 
two entries for the same NaN payload. That's a Go map artifact rather than set 
semantics we want to commit to; Java rejects NaN literals in `in`/`notIn` 
outright. Copy isolation and byte cloning are already covered by 
`TestBoundSetPredicateLiteralsIndependentCopies` and 
`TestBoundSetPredicateLiteralsCloneMutableMembers`, which both go red under the 
matching mutations, so I'd drop this one.



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