示例#1
0
 /**
  * Combines this bloom filter with another bloom filter by performing a bitwise OR of the
  * underlying data. The mutations happen to <b>this</b> instance. Callers must ensure the bloom
  * filters are appropriately sized to avoid saturating them.
  *
  * @param that The bloom filter to combine this bloom filter with. It is not mutated.
  * @throws IllegalArgumentException if {@code isCompatible(that) == false}
  * @since 15.0
  */
 public void putAll(BloomFilter<T> that) {
   checkNotNull(that);
   checkArgument(this != that, "Cannot combine a BloomFilter with itself.");
   checkArgument(
       this.numHashFunctions == that.numHashFunctions,
       "BloomFilters must have the same number of hash functions (%s != %s)",
       this.numHashFunctions,
       that.numHashFunctions);
   checkArgument(
       this.bitSize() == that.bitSize(),
       "BloomFilters must have the same size underlying bit arrays (%s != %s)",
       this.bitSize(),
       that.bitSize());
   checkArgument(
       this.strategy.equals(that.strategy),
       "BloomFilters must have equal strategies (%s != %s)",
       this.strategy,
       that.strategy);
   checkArgument(
       this.funnel.equals(that.funnel),
       "BloomFilters must have equal funnels (%s != %s)",
       this.funnel,
       that.funnel);
   this.bits.putAll(that.bits);
 }
示例#2
0
 /**
  * Determines whether a given bloom filter is compatible with this bloom filter. For two bloom
  * filters to be compatible, they must:
  *
  * <ul>
  *   <li>not be the same instance
  *   <li>have the same number of hash functions
  *   <li>have the same bit size
  *   <li>have the same strategy
  *   <li>have equal funnels
  *       <ul>
  *
  * @param that The bloom filter to check for compatibility.
  * @since 15.0
  */
 public boolean isCompatible(BloomFilter<T> that) {
   checkNotNull(that);
   return (this != that)
       && (this.numHashFunctions == that.numHashFunctions)
       && (this.bitSize() == that.bitSize())
       && (this.strategy.equals(that.strategy))
       && (this.funnel.equals(that.funnel));
 }