ScalableBloomFilter implements Serializable { public static Builder withMaximumSizeBytes(long maxBloomFilterSizeBytes) { checkArgument(maxBloomFilterSizeBytes > 0, "Expected Bloom filter size limit to be positive."); long optimalNumberOfElements = optimalNumInsertions(maxBloomFilterSizeBytes, DEFAULT_FALSE_POSITIVE_PROBABILITY); checkArgument( optimalNumberOfElements <= MAX_ELEMENTS, "The specified size limit would attempt to create a Bloom filter builder larger than " + "the maximum supported size of 2^63."); return withMaximumNumberOfInsertionsForOptimalBloomFilter(optimalNumberOfElements); } private  ScalableBloomFilter(BloomFilter<ByteBuffer> bloomFilter); boolean mightContain(byte[] buf, int offset, int length); boolean mightContain(ByteBuffer byteBuffer); @Override boolean equals(@Nullable Object other); @Override int hashCode(); @Override String toString(); static Builder withMaximumSizeBytes(long maxBloomFilterSizeBytes); static Builder withMaximumNumberOfInsertionsForOptimalBloomFilter(
      long maximumBloomFilterInsertionsForOptimalBloomFilter);  }
@Test public void testBuilder() throws Exception { Builder builder = ScalableBloomFilter.withMaximumSizeBytes(MAX_SIZE); assertTrue("Expected Bloom filter to have been modified.", builder.put(BUFFER)); assertFalse("Expected Bloom filter to not have been modified.", builder.put(BUFFER)); int maxValue = insertAndVerifyContents(builder, 31); verifyCoder(builder.build(), maxValue, MAX_SIZE / 50); }
@Test public void testBuilderWithMaxSize() throws Exception { Builder builder = ScalableBloomFilter.withMaximumSizeBytes(MAX_SIZE); int maxValue = insertAndVerifyContents(builder, (int) (MAX_SIZE * 1.1)); ScalableBloomFilter bloomFilter = builder.build(); verifyCoder(bloomFilter, maxValue, MAX_SIZE); }