Copilot commented on code in PR #799:
URL: 
https://github.com/apache/skywalking-banyandb/pull/799#discussion_r2393506266


##########
banyand/internal/sidx/merge_test.go:
##########
@@ -418,7 +418,7 @@ func Test_mergeParts(t *testing.T) {
                                        mp.mustInitFromElements(es)
                                        partPath := filepath.Join(tmpPath, 
"part_"+string(rune('0'+i)))
                                        mp.mustFlush(fileSystem, partPath)
-                                       filePart := mustOpenPart(partPath, 
fileSystem)
+                                       filePart := mustOpenPart(uint64(i), 
partPath, fileSystem)
                                        filePW := newPartWrapper(nil, filePart)
                                        filePW.p.partMetadata.ID = uint64(i)

Review Comment:
   The partID is being set twice - once in `mustOpenPart` call and again 
manually on line 423. The manual assignment on line 423 should be removed since 
`mustOpenPart` now handles setting the partID.
   ```suggestion
   
   ```



##########
banyand/internal/sidx/sidx.go:
##########
@@ -868,7 +867,7 @@ func (s *sidx) loadSnapshot(epoch uint64, loadedParts 
[]uint64) {
                        continue
                }
                partPath := partPath(s.root, id)
-               part := mustOpenPart(partPath, s.fileSystem)
+               part := mustOpenPart(id, partPath, s.fileSystem)
                part.partMetadata.ID = id

Review Comment:
   The partID is being set twice - once in `mustOpenPart` call and again 
manually on line 871. The manual assignment on line 871 should be removed since 
`mustOpenPart` now handles setting the partID.
   ```suggestion
   
   ```



##########
banyand/internal/sidx/part_wrapper.go:
##########
@@ -168,11 +168,7 @@ func (pw *partWrapper) markForRemoval() {
 }
 
 // ID returns the unique identifier of the part.
-// Returns 0 if the part is nil.
 func (pw *partWrapper) ID() uint64 {

Review Comment:
   Removing the nil checks could cause a panic if `pw.p` or `pw.p.partMetadata` 
is nil. The original nil checks were protecting against potential nil pointer 
dereferences.
   ```suggestion
   func (pw *partWrapper) ID() uint64 {
        if pw.p == nil || pw.p.partMetadata == nil {
                return 0
        }
   ```



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

Reply via email to