This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new d3da7a6b82 OAK-11852: Use new Bloom filter implementation in document
store (#2443)
d3da7a6b82 is described below
commit d3da7a6b82fefe8f02b8bc61fc99f9e5c7d9e0ed
Author: Julian Reschke <[email protected]>
AuthorDate: Tue Aug 12 14:58:06 2025 +0200
OAK-11852: Use new Bloom filter implementation in document store (#2443)
* OAK-11852: Use new Bloom filter implementation in document store
* OAK-11842: Copy Bloom Filter implementation from oak-run-commons to
oak-commons for re-use (#2432)
* OAK-11842: Copy Bloom Filter implementation from oak-run-commons to
oak-commons for re-use
* OAK-11842: Copy Bloom Filter implementation from oak-run-commons to
oak-commons for re-use - remove unintended changes
* OAK-11842 Bloom Filter: improve javadocs
---------
Co-authored-by: Thomas Mueller <[email protected]>
---------
Co-authored-by: Thomas Mueller <[email protected]>
---
.../document/cache/CacheChangesTracker.java | 44 ++++++++++------------
1 file changed, 19 insertions(+), 25 deletions(-)
diff --git
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/cache/CacheChangesTracker.java
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/cache/CacheChangesTracker.java
index 14e30cd673..196f6188d4 100644
---
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/cache/CacheChangesTracker.java
+++
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/cache/CacheChangesTracker.java
@@ -16,14 +16,13 @@
*/
package org.apache.jackrabbit.oak.plugins.document.cache;
-import org.apache.jackrabbit.guava.common.hash.BloomFilter;
-import org.apache.jackrabbit.guava.common.hash.Funnel;
-import org.apache.jackrabbit.guava.common.hash.PrimitiveSink;
+import org.apache.jackrabbit.oak.commons.collections.BloomFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
public class CacheChangesTracker implements Closeable {
@@ -62,10 +61,10 @@ public class CacheChangesTracker implements Closeable {
changeTrackers.remove(this);
if (LOG.isDebugEnabled()) {
- if (lazyBloomFilter.filter == null) {
+ if (lazyBloomFilter.filterRef.get() == null) {
LOG.debug("Disposing CacheChangesTracker for {}, no filter was
needed", keyFilter);
} else {
- LOG.debug("Disposing CacheChangesTracker for {}, filter fpp
was: {}", keyFilter, lazyBloomFilter.filter.expectedFpp());
+ LOG.debug("Disposing CacheChangesTracker for {}, filter fpp
was: {}", keyFilter, LazyBloomFilter.FPP);
}
}
}
@@ -76,38 +75,33 @@ public class CacheChangesTracker implements Closeable {
private final int entries;
- private volatile BloomFilter<String> filter;
+ private final AtomicReference<BloomFilter> filterRef;
public LazyBloomFilter(int entries) {
this.entries = entries;
+ this.filterRef = new AtomicReference<>();
}
public synchronized void put(String entry) {
- getFilter().put(entry);
+ getFilter().add(entry);
}
public boolean mightContain(String entry) {
- if (filter == null) {
- return false;
- } else {
- synchronized (this) {
- return filter.mightContain(entry);
- }
- }
+ BloomFilter f = filterRef.get();
+ return f != null && f.mayContain(entry);
}
- private BloomFilter<String> getFilter() {
- if (filter == null) {
- filter = BloomFilter.create(new Funnel<String>() {
- private static final long serialVersionUID =
-7114267990225941161L;
-
- @Override
- public void funnel(String from, PrimitiveSink into) {
- into.putUnencodedChars(from);
- }
- }, entries, FPP);
+ private BloomFilter getFilter() {
+ BloomFilter result = filterRef.get();
+ if (result == null) {
+ BloomFilter newFilter = BloomFilter.construct(entries, FPP);
+ if (filterRef.compareAndSet(null, newFilter)) {
+ result = newFilter;
+ } else {
+ result = filterRef.get();
+ }
}
- return filter;
+ return result;
}
}
}