Class BloomFilter
- java.lang.Object
-
- org.apache.accumulo.core.bloomfilter.Filter
-
- org.apache.accumulo.core.bloomfilter.BloomFilter
-
- All Implemented Interfaces:
org.apache.hadoop.io.Writable
public class BloomFilter extends Filter
Implements a Bloom filter, as defined by Bloom in 1970.The Bloom filter is a data structure that was introduced in 1970 and that has been adopted by the networking research community in the past decade thanks to the bandwidth efficiencies that it offers for the transmission of set membership information between networked hosts. A sender encodes the information into a bit vector, the Bloom filter, that is more compact than a conventional representation. Computation and space costs for construction are linear in the number of elements. The receiver uses the filter to test whether various elements are members of the set. Though the filter will occasionally return a false positive, it will never return a false negative. When creating the filter, the sender can choose its desired point in a trade-off between the false positive rate and the size.
Originally created by European Commission One-Lab Project 034819.
-
-
Field Summary
-
Fields inherited from class org.apache.accumulo.core.bloomfilter.Filter
hash, hashType, nbHash, vectorSize
-
-
Constructor Summary
Constructors Constructor Description BloomFilter()Default constructor - use with readFieldsBloomFilter(int vectorSize, int nbHash, int hashType)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(org.apache.hadoop.util.bloom.Key key)Adds a key to this filter.voidand(Filter filter)Performs a logical AND between this filter and a specified filter.intgetVectorSize()booleanmembershipTest(org.apache.hadoop.util.bloom.Key key)Determines whether a specified key belongs to this filter.voidnot()Performs a logical NOT on this filter.voidor(Filter filter)Performs a logical OR between this filter and a specified filter.voidreadFields(DataInput in)StringtoString()voidwrite(DataOutput out)voidxor(Filter filter)Performs a logical XOR between this filter and a specified filter.-
Methods inherited from class org.apache.accumulo.core.bloomfilter.Filter
getSerialVersion, getVersion
-
-
-
-
Constructor Detail
-
BloomFilter
public BloomFilter()
Default constructor - use with readFields
-
BloomFilter
public BloomFilter(int vectorSize, int nbHash, int hashType)Constructor- Parameters:
vectorSize- The vector size of this filter.nbHash- The number of hash function to consider.hashType- type of the hashing function (seeHash).
-
-
Method Detail
-
add
public boolean add(org.apache.hadoop.util.bloom.Key key)
Description copied from class:FilterAdds a key to this filter.
-
and
public void and(Filter filter)
Description copied from class:FilterPerforms a logical AND between this filter and a specified filter.Invariant: The result is assigned to this filter.
-
membershipTest
public boolean membershipTest(org.apache.hadoop.util.bloom.Key key)
Description copied from class:FilterDetermines whether a specified key belongs to this filter.- Specified by:
membershipTestin classFilter- Parameters:
key- The key to test.- Returns:
- boolean True if the specified key belongs to this filter. False otherwise.
-
not
public void not()
Description copied from class:FilterPerforms a logical NOT on this filter.The result is assigned to this filter.
-
or
public void or(Filter filter)
Description copied from class:FilterPerforms a logical OR between this filter and a specified filter.Invariant: The result is assigned to this filter.
-
xor
public void xor(Filter filter)
Description copied from class:FilterPerforms a logical XOR between this filter and a specified filter.Invariant: The result is assigned to this filter.
-
getVectorSize
public int getVectorSize()
- Returns:
- size of the the bloomfilter
-
write
public void write(DataOutput out) throws IOException
- Specified by:
writein interfaceorg.apache.hadoop.io.Writable- Overrides:
writein classFilter- Throws:
IOException
-
readFields
public void readFields(DataInput in) throws IOException
- Specified by:
readFieldsin interfaceorg.apache.hadoop.io.Writable- Overrides:
readFieldsin classFilter- Throws:
IOException
-
-