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


##########
banyand/trace/bloom_filter.go:
##########
@@ -43,3 +44,21 @@ func decodeBloomFilter(src []byte, bf *filter.BloomFilter) 
*filter.BloomFilter {
 
        return bf
 }
+
+func generateBloomFilter() *filter.BloomFilter {
+       v := bloomFilterPool.Get()
+       if v == nil {
+               return filter.NewBloomFilter(0)
+       }
+       return v

Review Comment:
   The pool.Get() method likely returns an interface{} or similar type that 
needs to be type-asserted to *filter.BloomFilter. The current code assumes v is 
already the correct type.
   ```suggestion
        bf, ok := v.(*filter.BloomFilter)
        if !ok {
                return filter.NewBloomFilter(0)
        }
        return bf
   ```



##########
banyand/trace/flusher.go:
##########
@@ -219,6 +219,7 @@ func (tst *tsTable) flush(snapshot *snapshot, flushCh chan 
*flusherIntroduction)
                partPath := partPath(tst.root, pw.ID())
                pw.mp.mustFlush(tst.fileSystem, partPath)
                newPW := newPartWrapper(nil, mustOpenFilePart(pw.ID(), 
tst.root, tst.fileSystem))
+               defer newPW.p.traceIDFilter.reset()
                newPW.p.partMetadata.ID = pw.ID()
                ind.flushed[newPW.ID()] = newPW
                partIDMap[newPW.ID()] = struct{}{}

Review Comment:
   The defer statement is placed incorrectly. It should be called after the 
partWrapper is no longer needed, not immediately after creation. This will 
reset the filter before it can be used by other parts of the system.
   ```suggestion
                newPW.p.partMetadata.ID = pw.ID()
                ind.flushed[newPW.ID()] = newPW
                partIDMap[newPW.ID()] = struct{}{}
                newPW.p.traceIDFilter.reset()
   ```



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