BloomFilter::put, (bf1, bf2) -> { bf1.putAll(bf2); return bf1; },
BloomFilter::put, (bf1, bf2) -> { bf1.putAll(bf2); return bf1; },
public void testPutAllWithSelf() { BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 1); try { assertFalse(bf1.isCompatible(bf1)); bf1.putAll(bf1); fail(); } catch (IllegalArgumentException expected) { } }
public void testPutAllDifferentSizes() { BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 1); BloomFilter<Integer> bf2 = BloomFilter.create(Funnels.integerFunnel(), 10); try { assertFalse(bf1.isCompatible(bf2)); bf1.putAll(bf2); fail(); } catch (IllegalArgumentException expected) { } try { assertFalse(bf2.isCompatible(bf1)); bf2.putAll(bf1); fail(); } catch (IllegalArgumentException expected) { } }
public void merge(BloomFilter<T> filter2) { filter.putAll(filter2.filter); }
public void testPutAll() { int element1 = 1; int element2 = 2; BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 100); bf1.put(element1); assertTrue(bf1.mightContain(element1)); assertFalse(bf1.mightContain(element2)); BloomFilter<Integer> bf2 = BloomFilter.create(Funnels.integerFunnel(), 100); bf2.put(element2); assertFalse(bf2.mightContain(element1)); assertTrue(bf2.mightContain(element2)); assertTrue(bf1.isCompatible(bf2)); bf1.putAll(bf2); assertTrue(bf1.mightContain(element1)); assertTrue(bf1.mightContain(element2)); assertFalse(bf2.mightContain(element1)); assertTrue(bf2.mightContain(element2)); }
/** * Merges the second bloom filter into the first. */ private static <E> BloomFilter<E> combineBloomFilter(BloomFilter<E> a, BloomFilter<E> b) { a.putAll(b); return a; }
public void putAll(LBF that) { bfs.putAll(that.bfs); }
BloomFilter::put, (bf1, bf2) -> { bf1.putAll(bf2); return bf1; },
BloomFilter::put, (bf1, bf2) -> { bf1.putAll(bf2); return bf1; },
/** * Combines {@code this} filter with another compatible filter. The mutations happen to {@code * this} instance. Callers must ensure {@code this} filter is appropriately sized to avoid * saturating it or running out of space. * * @param f filter to be combined into {@code this} filter - {@code f} is not mutated * @return {@code true} if the operation was successful, {@code false} otherwise * @throws NullPointerException if the specified filter is null * @throws IllegalArgumentException if {@link #isCompatible(ProbabilisticFilter)} {@code == * false} * @see #add(Object) * @see #addAll(Collection) * @see #contains(Object) */ public boolean addAll(ProbabilisticFilter<E> f) { checkNotNull(f); checkArgument(this != f, "Cannot combine a " + this.getClass().getSimpleName() + " with itself."); checkArgument(f instanceof BloomFilter, "Cannot combine a " + this.getClass().getSimpleName() + " with a " + f.getClass().getSimpleName()); checkArgument(this.isCompatible(f), "Cannot combine incompatible filters. " + this.getClass().getSimpleName() + " instances must have equivalent funnels; the same " + "strategy; and the same number of buckets, entries per bucket, and bits per entry."); delegate.putAll(((BloomFilter<E>) f).delegate); size = LongMath.checkedAdd(size, f.sizeLong()); return true; }
public void testPutAllWithSelf() { BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 1); try { assertFalse(bf1.isCompatible(bf1)); bf1.putAll(bf1); fail(); } catch (IllegalArgumentException expected) { } }
public void testPutAllDifferentSizes() { BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 1); BloomFilter<Integer> bf2 = BloomFilter.create(Funnels.integerFunnel(), 10); try { assertFalse(bf1.isCompatible(bf2)); bf1.putAll(bf2); fail(); } catch (IllegalArgumentException expected) { } try { assertFalse(bf2.isCompatible(bf1)); bf2.putAll(bf1); fail(); } catch (IllegalArgumentException expected) { } }
public void testPutAll() { int element1 = 1; int element2 = 2; BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 100); bf1.put(element1); assertTrue(bf1.mightContain(element1)); assertFalse(bf1.mightContain(element2)); BloomFilter<Integer> bf2 = BloomFilter.create(Funnels.integerFunnel(), 100); bf2.put(element2); assertFalse(bf2.mightContain(element1)); assertTrue(bf2.mightContain(element2)); assertTrue(bf1.isCompatible(bf2)); bf1.putAll(bf2); assertTrue(bf1.mightContain(element1)); assertTrue(bf1.mightContain(element2)); assertFalse(bf2.mightContain(element1)); assertTrue(bf2.mightContain(element2)); }