|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.hadoop.util.bloom.Filter org.apache.hadoop.util.bloom.BloomFilter
public class BloomFilter
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.
The general behavior of a filter
,
Space/Time Trade-Offs in Hash Coding with Allowable ErrorsField Summary |
---|
Fields inherited from class org.apache.hadoop.util.bloom.Filter |
---|
hash, hashType, nbHash, vectorSize |
Constructor Summary | |
---|---|
BloomFilter()
Default constructor - use with readFields |
|
BloomFilter(int vectorSize,
int nbHash,
int hashType)
Constructor |
Method Summary | |
---|---|
void |
add(Key key)
Adds a key to this filter. |
void |
and(Filter filter)
Peforms a logical AND between this filter and a specified filter. |
int |
getVectorSize()
|
boolean |
membershipTest(Key key)
Determines wether a specified key belongs to this filter. |
void |
not()
Performs a logical NOT on this filter. |
void |
or(Filter filter)
Peforms a logical OR between this filter and a specified filter. |
void |
readFields(DataInput in)
Deserialize the fields of this object from in . |
String |
toString()
|
void |
write(DataOutput out)
Serialize the fields of this object to out . |
void |
xor(Filter filter)
Peforms a logical XOR between this filter and a specified filter. |
Methods inherited from class org.apache.hadoop.util.bloom.Filter |
---|
add, add, add |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BloomFilter()
public BloomFilter(int vectorSize, int nbHash, int hashType)
vectorSize
- The vector size of this filter.nbHash
- The number of hash function to consider.hashType
- type of the hashing function (see
Hash
).Method Detail |
---|
public void add(Key key)
Filter
add
in class Filter
key
- The key to add.public void and(Filter filter)
Filter
Invariant: The result is assigned to this filter.
and
in class Filter
filter
- The filter to AND with.public boolean membershipTest(Key key)
Filter
membershipTest
in class Filter
key
- The key to test.
public void not()
Filter
The result is assigned to this filter.
not
in class Filter
public void or(Filter filter)
Filter
Invariant: The result is assigned to this filter.
or
in class Filter
filter
- The filter to OR with.public void xor(Filter filter)
Filter
Invariant: The result is assigned to this filter.
xor
in class Filter
filter
- The filter to XOR with.public String toString()
toString
in class Object
public int getVectorSize()
public void write(DataOutput out) throws IOException
Writable
out
.
write
in interface Writable
write
in class Filter
out
- DataOuput
to serialize this object into.
IOException
public void readFields(DataInput in) throws IOException
Writable
in
.
For efficiency, implementations should attempt to re-use storage in the existing object where possible.
readFields
in interface Writable
readFields
in class Filter
in
- DataInput
to deseriablize this object from.
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |