Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated abstract class to reflect changes in previous commit
  • Loading branch information
Bcpoole committed Feb 9, 2017
commit 501ad7e22101b00862c0c77ef8c38e1b166d33a4
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ int getVersionNumber() {
*/
public abstract boolean mightContainBinary(byte[] item);

/**
* Returns a new Bloom filter of the union of two Bloom filters.
* Unlike mergeInplace, this will not cause a mutation.
* Callers must ensure the bloom filters are appropriately sized to avoid saturating them.
*
* @throws IncompatibleUnionException if either are null, different classes, or different size or number of hash functions
*/
public abstract BloomFilterImpl createUnionBloomFilter(BloomFilter other) throws IncompatibleUnionException;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about just calling this union?


/**
* Swamidass & Baldi (2007) approximation for number of items in the intersection of two Bloom filters
Copy link
Contributor

@mengxr mengxr Feb 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Same here. Document the method first and then mention the reference.
  • How is it different from intersecting two bloom filters and then estimate the number of items? Union might lead to larger approximation error. Okay, I got why. Please also document it.

*/
public abstract double approxItemsInIntersection(BloomFilter that) throws IncompatibleUnionException;

/**
* Writes out this {@link BloomFilter} to an output stream in binary format. It is the caller's
* responsibility to close the stream.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,7 @@ public double approxItems() {
return (m / numHashFunctions) * Math.log(1 - (bits.cardinality() / m));
}

/**
* Returns a new Bloom filter of the union of two Bloom filters.
* Unlike mergeInplace, this will not cause a mutation.
* Callers must ensure the bloom filters are appropriately sized to avoid saturating them.
*
* @throws IncompatibleUnionException if either are null, different classes, or different size or number of hash functions
*/
@Override
public BloomFilterImpl createUnionBloomFilter(BloomFilter other) throws IncompatibleUnionException {
// Duplicates the logic of `isCompatible` here to provide better error message.
if (other == null) {
Expand Down Expand Up @@ -262,9 +256,7 @@ public BloomFilterImpl createUnionBloomFilter(BloomFilter other) throws Incompat
return bfUnion;
}

/**
* Swamidass & Baldi (2007) approximation for number of items in the intersection of two Bloom filters
*/
@Override
public double approxItemsInIntersection(BloomFilter that) throws IncompatibleUnionException {
BloomFilterImpl union = createUnionBloomFilter(that);

Expand Down