public class BloomFilter extends Object
Internally, this implementation of bloom filter uses Murmur3 fast non-cryptographic hash algorithm. Although Murmur2 is slightly faster than Murmur3 in Java, it suffers from hash collisions for specific sequence of repeating bytes. Check the following link for more info https://code.google.com/p/smhasher/wiki/MurmurHash2Flaw
Note that this class is here for backwards compatibility, because it uses the JVM default character set for strings. All new users should BloomFilterUtf8, which always uses UTF8 for the encoding.
Modifier and Type | Class and Description |
---|---|
static class |
BloomFilter.BitSet
Bare metal bit set implementation.
|
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_FPP |
Constructor and Description |
---|
BloomFilter(long expectedEntries) |
BloomFilter(long[] bits,
int numFuncs)
A constructor to support rebuilding the BloomFilter from a serialized representation.
|
BloomFilter(long expectedEntries,
double fpp) |
Modifier and Type | Method and Description |
---|---|
void |
add(byte[] val) |
void |
addBytes(byte[] val,
int offset,
int length) |
void |
addDouble(double val) |
void |
addLong(long val) |
void |
addString(String val) |
boolean |
equals(Object other) |
long[] |
getBitSet() |
int |
getBitSize() |
int |
getNumHashFunctions() |
int |
hashCode() |
void |
merge(BloomFilter that)
Merge the specified bloom filter with current bloom filter.
|
void |
reset() |
long |
sizeInBytes() |
boolean |
test(byte[] val) |
boolean |
testBytes(byte[] val,
int offset,
int length) |
boolean |
testDouble(double val) |
boolean |
testLong(long val) |
boolean |
testString(String val) |
String |
toString() |
public static final double DEFAULT_FPP
public BloomFilter(long expectedEntries)
public BloomFilter(long expectedEntries, double fpp)
public BloomFilter(long[] bits, int numFuncs)
bits
- the serialized bitsnumFuncs
- the number of functions usedpublic void add(byte[] val)
public void addBytes(byte[] val, int offset, int length)
public void addString(String val)
public void addLong(long val)
public void addDouble(double val)
public boolean test(byte[] val)
public boolean testBytes(byte[] val, int offset, int length)
public boolean testString(String val)
public boolean testLong(long val)
public boolean testDouble(double val)
public long sizeInBytes()
public int getBitSize()
public int getNumHashFunctions()
public long[] getBitSet()
public void merge(BloomFilter that)
that
- - bloom filter to mergepublic void reset()
Copyright © 2013–2023 The Apache Software Foundation. All rights reserved.