BloomFilter implements Serializable { public void merge(BloomFilter<T> filter2) { filter.putAll(filter2.filter); } BloomFilter(Function<T, byte[]> serializer, int expectedInsertions, double falsePositiveRate); boolean mightContain(T key); void add(T key); void merge(BloomFilter<T> filter2); @Override boolean equals(Object o); @Override int hashCode();  }
@Test @SuppressWarnings("unchecked") public void testMerge() { BloomFilter bloomString = (BloomFilter)run("BLOOM_ADD(BLOOM_INIT(), string)", variables); BloomFilter bloomDouble = (BloomFilter)run("BLOOM_ADD(BLOOM_INIT(), double)", variables); BloomFilter bloomInteger= (BloomFilter)run("BLOOM_ADD(BLOOM_INIT(), integer)", variables); BloomFilter bloomMap= (BloomFilter)run("BLOOM_ADD(BLOOM_INIT(), map)", variables); BloomFilter merged = (BloomFilter)run("BLOOM_MERGE([stringFilter, doubleFilter, integerFilter, mapFilter])" , ImmutableMap.of("stringFilter", bloomString ,"doubleFilter", bloomDouble ,"integerFilter", bloomInteger ,"mapFilter", bloomMap ) ); assertNotNull(merged); for(Object val : variables.values()) { assertTrue(merged.mightContain(val)); } }