org.onelab.filter
Class DynamicBloomFilter

java.lang.Object
  extended by org.onelab.filter.Filter
      extended by org.onelab.filter.DynamicBloomFilter
All Implemented Interfaces:
Comparable, Writable, WritableComparable

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 * 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. contract European Commission One-Lab Project 034819.

Version:
1.0 - 6 Feb. 07
See Also:
The general behavior of a filter, A Bloom filter, Theory and Network Applications of Dynamic Bloom Filters

Field Summary
 
Fields inherited from class org.onelab.filter.Filter
hash
 
Constructor Summary
DynamicBloomFilter(int vectorSize, int nbHash, int nr)
          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.
 Object clone()
          
 int compareTo(Object o)
          
 boolean equals(Object o)
          
 int hashCode()
          
 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.

For efficiency, implementations should attempt to re-use storage in the existing object where possible.

 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.onelab.filter.Filter
add, add, add
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DynamicBloomFilter

public DynamicBloomFilter(int vectorSize,
                          int nbHash,
                          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.
nr - The threshold for the maximum number of keys to record in a dynamic Bloom filter row.
Method Detail

add

public void add(Key key)
Adds a key to this filter.

Specified by:
add in class Filter
Parameters:
key - The key to add.

and

public void and(Filter filter)
Peforms a logical AND between this filter and a specified filter.

Invariant: The result is assigned to this filter.

Specified by:
and in class Filter
Parameters:
filter - The filter to AND with.

membershipTest

public boolean membershipTest(Key key)
Determines wether a specified key belongs to this filter.

Specified by:
membershipTest in class Filter
Parameters:
key - The key to test.
Returns:
boolean True if the specified key belongs to this filter. False otherwise.

not

public void not()
Performs a logical NOT on this filter.

The result is assigned to this filter.

Specified by:
not in class Filter

or

public void or(Filter filter)
Peforms a logical OR between this filter and a specified filter.

Invariant: The result is assigned to this filter.

Specified by:
or in class Filter
Parameters:
filter - The filter to OR with.

xor

public void xor(Filter filter)
Peforms a logical XOR between this filter and a specified filter.

Invariant: The result is assigned to this filter.

Specified by:
xor in class Filter
Parameters:
filter - The filter to XOR with.

toString

public String toString()

Overrides:
toString in class Object

clone

public Object clone()

Overrides:
clone in class Object

equals

public boolean equals(Object o)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Filter

write

public void write(DataOutput out)
           throws IOException
Serialize the fields of this object to out.

Specified by:
write in interface Writable
Overrides:
write in class Filter
Parameters:
out - DataOuput to serialize this object into.
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Deserialize the fields of this object from in.

For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface Writable
Overrides:
readFields in class Filter
Parameters:
in - DataInput to deseriablize this object from.
Throws:
IOException

compareTo

public int compareTo(Object o)

Specified by:
compareTo in interface Comparable
Overrides:
compareTo in class Filter


Copyright © 2006 The Apache Software Foundation