@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } HiveBloomFilter that = (HiveBloomFilter) o; return Objects.equals(numBits, that.numBits) && Objects.equals(numHashFunctions, that.numHashFunctions) && Arrays.equals(bitSet.getData(), that.bitSet.getData()); }
/** * Merge the specified bloom filter with current bloom filter. * * @param that - bloom filter to merge */ public void merge(BloomFilter that) { if (this != that && this.numBits == that.numBits && this.numHashFunctions == that.numHashFunctions) { this.bitSet.putAll(that.bitSet); } else { throw new IllegalArgumentException("BloomFilters are not compatible for merging." + " this - " + this.toString() + " that - " + that.toString()); } }
private boolean testHash(long hash64) { int hash1 = (int) hash64; int hash2 = (int) (hash64 >>> 32); for (int i = 1; i <= numHashFunctions; i++) { int combinedHash = hash1 + (i * hash2); // hashcode should be positive, flip all the bits if it's negative if (combinedHash < 0) { combinedHash = ~combinedHash; } int pos = combinedHash % numBits; if (!bitSet.get(pos)) { return false; } } return true; }
private boolean testHash(long hash64) { int hash1 = (int) hash64; int hash2 = (int) (hash64 >>> 32); for (int i = 1; i <= numHashFunctions; i++) { int combinedHash = hash1 + ((i + 1) * hash2); // hashcode should be positive, flip all the bits if it's negative if (combinedHash < 0) { combinedHash = ~combinedHash; } int pos = combinedHash % numBits; if (!bitSet.get(pos)) { return false; } } return true; }
public void reset() { this.bitSet.clear(); }
public int getBitSize() { return bitSet.getData().length * Long.SIZE; }
public long[] getBitSet() { return bitSet.getData(); }
public int getBitSize() { return bitSet.getData().length * Long.SIZE; }
public void reset() { this.bitSet.clear(); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } HiveBloomFilter that = (HiveBloomFilter) o; return Objects.equals(numBits, that.numBits) && Objects.equals(numHashFunctions, that.numHashFunctions) && Arrays.equals(bitSet.getData(), that.bitSet.getData()); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } HiveBloomFilter that = (HiveBloomFilter) o; return Objects.equals(numBits, that.numBits) && Objects.equals(numHashFunctions, that.numHashFunctions) && Arrays.equals(bitSet.getData(), that.bitSet.getData()); }
public long getRetainedSizeInBytes() { return INSTANCE_SIZE + sizeOf(bitSet.getData()); }
/** * Merge the specified bloom filter with current bloom filter. * * @param that - bloom filter to merge */ public void merge(BloomFilter that) { if (this != that && this.numBits == that.numBits && this.numHashFunctions == that.numHashFunctions) { this.bitSet.putAll(that.bitSet); } else { throw new IllegalArgumentException("BloomFilters are not compatible for merging." + " this - " + this.toString() + " that - " + that.toString()); } }
private void addHash(long hash64) { int hash1 = (int) hash64; int hash2 = (int) (hash64 >>> 32); for (int i = 1; i <= numHashFunctions; i++) { int combinedHash = hash1 + ((i + 1) * hash2); // hashcode should be positive, flip all the bits if it's negative if (combinedHash < 0) { combinedHash = ~combinedHash; } int pos = combinedHash % numBits; bitSet.set(pos); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } HiveBloomFilter that = (HiveBloomFilter) o; return Objects.equals(numBits, that.numBits) && Objects.equals(numHashFunctions, that.numHashFunctions) && Arrays.equals(bitSet.getData(), that.bitSet.getData()); }
public long getRetainedSizeInBytes() { return INSTANCE_SIZE + sizeOf(bitSet.getData()); }
public long[] getBitSet() { return bitSet.getData(); }
public long getRetainedSizeInBytes() { return INSTANCE_SIZE + sizeOf(bitSet.getData()); }
/** * Merge the specified bloom filter with current bloom filter. * * @param that - bloom filter to merge */ public void merge(BloomFilter that) { if (this != that && this.numBits == that.numBits && this.numHashFunctions == that.numHashFunctions) { this.bitSet.putAll(that.bitSet); } else { throw new IllegalArgumentException("BloomFilters are not compatible for merging." + " this - " + this.toString() + " that - " + that.toString()); } }
private void addHash(long hash64) { int hash1 = (int) hash64; int hash2 = (int) (hash64 >>> 32); for (int i = 1; i <= numHashFunctions; i++) { int combinedHash = hash1 + (i * hash2); // hashcode should be positive, flip all the bits if it's negative if (combinedHash < 0) { combinedHash = ~combinedHash; } int pos = combinedHash % numBits; bitSet.set(pos); } }