Class DynamicBloomFilter
- java.lang.Object
-
- org.apache.accumulo.core.bloomfilter.Filter
-
- org.apache.accumulo.core.bloomfilter.DynamicBloomFilter
-
- All Implemented Interfaces:
org.apache.hadoop.io.Writable
public class DynamicBloomFilter extends Filter
Implements a dynamic Bloom filter, as defined in the INFOCOM 2006 paper.A dynamic Bloom filter (DBF) makes use of a
s * mbit matrix but each of thesrows is a standard Bloom filter. The creation process of a DBF is iterative. At the start, the DBF is a1 * mbit matrix, i.e., it is composed of a single standard Bloom filter. It assumes thatnrelements are recorded in the initial bit vector, wherenr <= n(nis the cardinality of the setAto record in the filter).As the size of
Agrows during the execution of the application, several keys must be inserted in the DBF. When inserting a key into the DBF, one must first get an active Bloom filter in the matrix. A Bloom filter is active when the number of recorded keys,nr, is strictly less than the current cardinality ofA,n. If an active Bloom filter is found, the key is inserted andnris incremented by one. On the other hand, if there is no active Bloom filter, a new one is created (i.e., a new row is added to the matrix) according to the current size ofAand the element is added in this new Bloom filter and thenrvalue of this new Bloom filter is set to one. A given key is said to belong to the DBF if thekpositions are set to one in one of the matrix rows.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 DynamicBloomFilter()Zero-args constructor for the serialization.DynamicBloomFilter(int vectorSize, int nbHash, int hashType, int nr)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.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
-
DynamicBloomFilter
public DynamicBloomFilter()
Zero-args constructor for the serialization.
-
DynamicBloomFilter
public DynamicBloomFilter(int vectorSize, int nbHash, int hashType, int nr)Constructor.Builds an empty Dynamic Bloom filter.
- Parameters:
vectorSize- The number of bits in the vector.nbHash- The number of hash function to consider.hashType- type of the hashing function (seeHash).nr- The threshold for the maximum number of keys to record in a dynamic Bloom filter row.
-
-
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.
-
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
-
-