Class DynamicBloomFilter
- All Implemented Interfaces:
Writable
A dynamic Bloom filter (DBF) makes use of a s * m bit matrix but
each of the s rows is a standard Bloom filter. The creation
process of a DBF is iterative. At the start, the DBF is a 1 * m
bit matrix, i.e., it is composed of a single standard Bloom filter.
It assumes that nr elements are recorded in the
initial bit vector, where nr <= n
(n is the cardinality of the set A to record in
the filter).
As the size of A grows 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 of A, n.
If an active Bloom filter is found, the key is inserted and
nr is 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 of A and the element
is added in this new Bloom filter and the nr value of
this new Bloom filter is set to one. A given key is said to belong to the
DBF if the k positions 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.hadoop.util.bloom.Filter
hash, hashType, nbHash, vectorSize -
Constructor Summary
ConstructorsConstructorDescriptionZero-args constructor for the serialization.DynamicBloomFilter(int vectorSize, int nbHash, int hashType, int nr) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a key to this filter.voidPeforms a logical AND between this filter and a specified filter.booleanmembershipTest(Key key) Determines wether a specified key belongs to this filter.voidnot()Performs a logical NOT on this filter.voidPeforms a logical OR between this filter and a specified filter.voidreadFields(DataInput in) Deserialize the fields of this object fromin.toString()voidwrite(DataOutput out) Serialize the fields of this object toout.voidPeforms a logical XOR between this filter and a specified filter.
-
Constructor Details
-
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 Details
-
add
Description copied from class:FilterAdds a key to this filter. -
and
Description copied from class:FilterPeforms a logical AND between this filter and a specified filter.Invariant: The result is assigned to this filter.
-
membershipTest
Description copied from class:FilterDetermines wether 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
Description copied from class:FilterPeforms a logical OR between this filter and a specified filter.Invariant: The result is assigned to this filter.
-
xor
Description copied from class:FilterPeforms a logical XOR between this filter and a specified filter.Invariant: The result is assigned to this filter.
-
toString
-
write
Description copied from interface:WritableSerialize the fields of this object toout.- Specified by:
writein interfaceWritable- Overrides:
writein classFilter- Parameters:
out-DataOuputto serialize this object into.- Throws:
IOException- any other problem for write.
-
readFields
Description copied from interface:WritableDeserialize the fields of this object fromin.For efficiency, implementations should attempt to re-use storage in the existing object where possible.
- Specified by:
readFieldsin interfaceWritable- Overrides:
readFieldsin classFilter- Parameters:
in-DataInputto deseriablize this object from.- Throws:
IOException- any other problem for readFields.
-