This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 3ce8fda9d [core] FileBasedBloomFilter should not be pass private 
member to cache manager. (#4118)
3ce8fda9d is described below

commit 3ce8fda9d6bd50c87c652375c6a24492695c4cdf
Author: YeJunHao <[email protected]>
AuthorDate: Tue Sep 3 16:30:15 2024 +0800

    [core] FileBasedBloomFilter should not be pass private member to cache 
manager. (#4118)
---
 .../org/apache/paimon/utils/FileBasedBloomFilter.java  | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git 
a/paimon-common/src/main/java/org/apache/paimon/utils/FileBasedBloomFilter.java 
b/paimon-common/src/main/java/org/apache/paimon/utils/FileBasedBloomFilter.java
index f80ba301e..7b885a5e6 100644
--- 
a/paimon-common/src/main/java/org/apache/paimon/utils/FileBasedBloomFilter.java
+++ 
b/paimon-common/src/main/java/org/apache/paimon/utils/FileBasedBloomFilter.java
@@ -20,6 +20,7 @@ package org.apache.paimon.utils;
 
 import org.apache.paimon.annotation.VisibleForTesting;
 import org.apache.paimon.io.PageFileInput;
+import org.apache.paimon.io.cache.CacheCallback;
 import org.apache.paimon.io.cache.CacheKey;
 import org.apache.paimon.io.cache.CacheManager;
 import org.apache.paimon.memory.MemorySegment;
@@ -62,7 +63,7 @@ public class FileBasedBloomFilter {
                     cacheManager.getPage(
                             CacheKey.forPosition(input.file(), readOffset, 
readLength),
                             key -> input.readPosition(readOffset, readLength),
-                            key -> filter.unsetMemorySegment());
+                            new BloomFilterCallBack(filter));
             filter.setMemorySegment(segment, 0);
             accessCount = 0;
         }
@@ -73,4 +74,19 @@ public class FileBasedBloomFilter {
     BloomFilter bloomFilter() {
         return filter;
     }
+
+    /** Call back for cache manager. */
+    private static class BloomFilterCallBack implements CacheCallback {
+
+        private final BloomFilter bloomFilter;
+
+        private BloomFilterCallBack(BloomFilter bloomFilter) {
+            this.bloomFilter = bloomFilter;
+        }
+
+        @Override
+        public void onRemoval(CacheKey key) {
+            this.bloomFilter.unsetMemorySegment();
+        }
+    }
 }

Reply via email to