Rice Pastry API

rice.p2p.util
Class IdBloomFilter

java.lang.Object
  extended byrice.p2p.util.IdBloomFilter
All Implemented Interfaces:
java.io.Serializable

public class IdBloomFilter
extends java.lang.Object
implements java.io.Serializable

Version:
$Id: IdBloomFilter.java 3274 2006-05-15 16:17:47Z jeffh $
Author:
Alan Mislove
See Also:
Serialized Form

Field Summary
protected  byte[] array
          An internal byte[] for managing ids in a memory-efficent manner
protected  BloomFilter filter
          The parameters to the hash functions for this bloom filter
static int NUM_BITS_PER_KEY
          The number of bits per key in bloom filters
static int NUM_HASH_FUNCTIONS
          The number of different hash functions to use in bloom filters
 
Constructor Summary
IdBloomFilter(IdSet set)
          Constructor which takes the number of hash functions to use and the length of the set to use.
IdBloomFilter(InputBuffer buf)
          Constructor for IdBloomFilter.
 
Method Summary
protected  void addId(Id id)
          Method which adds an Id to the underlying bloom filter
 boolean check(Id id)
          Method which returns whether or not an Id *may* be in the set.
 void check(IdSet set, IdSet result, int max)
          Method which checks an entire IdSet to see if they exist in this bloom filter, and returns the response by adding elements to the other provided id set.
protected  void checkArray(Id id)
          Internal method for checking to see if the array exists, and if not, instanciating it.
 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

array

protected transient byte[] array
An internal byte[] for managing ids in a memory-efficent manner


filter

protected BloomFilter filter
The parameters to the hash functions for this bloom filter


NUM_BITS_PER_KEY

public static int NUM_BITS_PER_KEY
The number of bits per key in bloom filters


NUM_HASH_FUNCTIONS

public static int NUM_HASH_FUNCTIONS
The number of different hash functions to use in bloom filters

Constructor Detail

IdBloomFilter

public IdBloomFilter(IdSet set)
Constructor which takes the number of hash functions to use and the length of the set to use.

Parameters:
set - DESCRIBE THE PARAMETER

IdBloomFilter

public IdBloomFilter(InputBuffer buf)
              throws java.io.IOException
Constructor for IdBloomFilter.

Parameters:
buf - DESCRIBE THE PARAMETER
Throws:
java.io.IOException - DESCRIBE THE EXCEPTION
Method Detail

checkArray

protected void checkArray(Id id)
Internal method for checking to see if the array exists, and if not, instanciating it. It also places the given Id into the array.

Parameters:
id - An id to build the array from

addId

protected void addId(Id id)
Method which adds an Id to the underlying bloom filter

Parameters:
id - The id to add

check

public boolean check(Id id)
Method which returns whether or not an Id *may* be in the set. Specifically, if this method returns false, the element is definately not in the set. Otherwise, if true is returned, the element may be in the set, but it is not guaranteed.

Parameters:
id - The id to check for
Returns:
DESCRIBE THE RETURN VALUE

check

public void check(IdSet set,
                  IdSet result,
                  int max)
Method which checks an entire IdSet to see if they exist in this bloom filter, and returns the response by adding elements to the other provided id set.

Parameters:
set - THe set to check for
result - The set to put the non-existing objects into
max - The maximum number of keys to return

serialize

public void serialize(OutputBuffer buf)
               throws java.io.IOException
DESCRIBE THE METHOD

Parameters:
buf - DESCRIBE THE PARAMETER
Throws:
java.io.IOException - DESCRIBE THE EXCEPTION

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection