Skip to content

Commit

Permalink
[core] FileBasedBloomFilter should not be pass private member to cach…
Browse files Browse the repository at this point in the history
…e manager. (apache#4118)
  • Loading branch information
leaves12138 authored Sep 3, 2024
1 parent 6b8d72b commit 3ce8fda
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

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;
Expand Down Expand Up @@ -62,7 +63,7 @@ public boolean testHash(int hash) {
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;
}
Expand All @@ -73,4 +74,19 @@ public boolean testHash(int hash) {
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();
}
}
}

0 comments on commit 3ce8fda

Please sign in to comment.