zeroshade commented on code in PR #2377:
URL: https://github.com/apache/iceberg-go/pull/2377#discussion_r4469638095
##########
table/compaction/compaction.go:
##########
@@ -344,15 +346,37 @@ func (cfg Config) PlanCompaction(tasks
[]table.FileScanTask) (Plan, error) {
return plan, nil
}
+// sameCompactionOptionalInt64 compares the values, not pointer identities:
+// independently decoded scan tasks may have distinct pointers.
+func sameCompactionOptionalInt64(a, b *int64) bool {
+ if a == nil || b == nil {
+ return a == b
+ }
+
+ return *a == *b
+}
+
func sameCompactionMetadata(a, b table.FileScanTask) bool {
equalDataFiles := func(a, b []iceberg.DataFile) bool {
+ if len(a) != len(b) {
+ return false
+ }
+ // Scan planning commonly reuses the same immutable delete-file
slice
+ // for every split of a physical file. Equal slice headers
prove equal
Review Comment:
Nit: the capacities can differ, so "equal slice headers" is slightly loose —
consider "same backing array and length prove identical elements".
##########
table/compaction/compaction_normalization_perf_test.go:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package compaction_test
+
+import (
+ "fmt"
+ "slices"
+ "testing"
+
+ "github.com/apache/iceberg-go"
+ "github.com/apache/iceberg-go/table"
+ "github.com/apache/iceberg-go/table/compaction"
+ "github.com/stretchr/testify/require"
+)
+
+func TestPlanCompactionSplitMetadataSharedAndCopiedDeletes(t *testing.T) {
+ file := newDataFile("shared.parquet", 10)
+ rowID, sequence := int64(17), int64(9)
+ first := makeTask(file, 0, 0)
+ first.DeleteFiles = []iceberg.DataFile{newDeleteFile("a.pos"),
newDeleteFile("b.pos")}
+ first.FirstRowID, first.DataSequenceNumber = &rowID, &sequence
+
+ // The ordinary split path retains the same delete slice.
+ shared := first
+ shared.Start = file.size / 3
+ // A remote or independently decoded task may have equal values but
+ // different slice and pointer identities. It must still be accepted.
+ copied := first
+ copied.Start = 2 * file.size / 3
+ copied.DeleteFiles = []iceberg.DataFile{newDeleteFile("a.pos"),
newDeleteFile("b.pos")}
+ copiedRowID, copiedSequence := rowID, sequence
+ copied.FirstRowID, copied.DataSequenceNumber = &copiedRowID,
&copiedSequence
+
+ cfg := compaction.DefaultConfig()
+ cfg.MinInputFiles = 1
+ plan, err := cfg.PlanCompaction([]table.FileScanTask{first, shared,
copied})
+ require.NoError(t, err)
+ require.Equal(t, 1, plan.TotalInputFiles)
+ require.Len(t, plan.Groups, 1)
+ require.Len(t, plan.Groups[0].Tasks, 1)
+ require.Equal(t, 2, plan.Groups[0].DeleteFileCount)
+
+ // Matching paths are not enough: a separately decoded delete with
different
Review Comment:
This comment says matching paths aren't enough, but the case below changes
the path to `other.pos`. The real same-path case is already covered by "same
delete path, different metadata" in
`TestPlanCompactionRejectsConflictingSplitMetadata`.
##########
table/compaction/compaction_normalization_perf_test.go:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package compaction_test
+
+import (
+ "fmt"
+ "slices"
+ "testing"
+
+ "github.com/apache/iceberg-go"
+ "github.com/apache/iceberg-go/table"
+ "github.com/apache/iceberg-go/table/compaction"
+ "github.com/stretchr/testify/require"
+)
+
+func TestPlanCompactionSplitMetadataSharedAndCopiedDeletes(t *testing.T) {
Review Comment:
Most of this overlaps existing tests: the copied-list/pointer acceptance is
covered by `TestPlanCompactionCountsWholeFiles`, and the rejection by
`TestPlanCompactionRejectsConflictingSplitMetadata`. Could you keep only the
shared-list-acceptance part (the genuinely new case) and move it into
`compaction_file_grain_test.go` next to the related split-metadata tests?
--
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]