|
Rice Pastry API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rice.p2p.util.BloomFilter
Field Summary | |
protected int |
length
The length of the set to use |
static int |
PARAMETER_LENGTH
The length of the random byte arrays which are generated |
protected int[] |
parameters
The parameters to the hash functions for this bloom filter |
protected java.util.BitSet |
set
The underlying bitset representation for this bloom filter |
Constructor Summary | |
BloomFilter(InputBuffer buf)
Constructor for BloomFilter. |
|
BloomFilter(int num,
int length)
Constructor which takes the number of hash functions to use and the length of the set to use. |
Method Summary | |
void |
add(byte[] array)
Method which adds an element to this bloom filter. |
boolean |
check(byte[] array)
Method which returns whether or not an element *may* be in the set. |
protected int |
doHash(byte[] array,
int seed)
Method which performs a dumb hash of the provided array and the seed value. |
java.lang.String |
getBitSet()
Method which returns what the internal bit set looks like as a string |
protected int |
hash(byte[] array,
int i)
Internal method which hashes the input argument using the ith hash function, and then mods the result by length. |
static void |
main(java.lang.String[] args)
Test serialize/deserialize |
void |
serialize(OutputBuffer buf)
DESCRIBE THE METHOD |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int[] parameters
protected int length
protected java.util.BitSet set
public static int PARAMETER_LENGTH
Constructor Detail |
public BloomFilter(int num, int length)
num
- The number of hash functions to uselength
- The length of the underlying bit setpublic BloomFilter(InputBuffer buf) throws java.io.IOException
buf
- DESCRIBE THE PARAMETER
java.io.IOException
- DESCRIBE THE EXCEPTIONMethod Detail |
public java.lang.String getBitSet()
public void add(byte[] array)
array
- The element to addpublic boolean check(byte[] array)
array
- The element to check for
protected int hash(byte[] array, int i)
array
- The element to hashi
- The hash function to use
protected int doHash(byte[] array, int seed)
array
- The input arrayseed
- DESCRIBE THE PARAMETER
public void serialize(OutputBuffer buf) throws java.io.IOException
buf
- DESCRIBE THE PARAMETER
java.io.IOException
- DESCRIBE THE EXCEPTIONpublic static void main(java.lang.String[] args) throws java.io.IOException
args
-
java.io.IOException
- DESCRIBE THE EXCEPTION
|
Rice Pastry API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |