zeroshade commented on code in PR #864:
URL: https://github.com/apache/arrow-go/pull/864#discussion_r3560213768


##########
parquet/metadata/bloom_filter.go:
##########
@@ -552,6 +554,46 @@ func (r *RowGroupBloomFilterReader) GetColumnBloomFilter(i 
int) (BloomFilter, er
        return bf, nil
 }
 
+// VisitColumnBloomFilter invokes fn for the BloomFilter of the column at 
index i.
+//
+// Lifetime contract: The BloomFilter passed to fn (and its backing bitset)
+// is recycled immediately after fn returns. Callers must not retain, store,
+// or use the BloomFilter or its data outside the scope of the fn function.
+func (r *RowGroupBloomFilterReader) VisitColumnBloomFilter(i int, fn 
func(BloomFilter) error) error {
+       bf, err := r.GetColumnBloomFilter(i)
+       if err != nil || bf == nil {
+               return err
+       }
+
+       defer r.recycle(bf)
+
+       return fn(bf)
+}
+
+func (r *RowGroupBloomFilterReader) recycle(bf BloomFilter) {
+       if bf == nil {
+               return
+       }
+
+       b, ok := bf.(*blockSplitBloomFilter)
+       if !ok {
+               return
+       }
+
+       b.bitset32 = nil
+
+       if r.bufferPool != nil && b.cancelCleanup != nil {
+               // Stop the GC cleanup so it can't return b.data to the pool a 
second time.
+               b.cancelCleanup()
+               b.cancelCleanup = nil
+               r.bufferPool.Put(b.data)

Review Comment:
   needs a call to `ResizeNoShrink(0)` first



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