Implement bloom filter operations. More...
Public Member Functions | |
BloomFilter (int estimatedMembers, byte[] seed) | |
Constructor. | |
BloomFilter () | |
For decoding. | |
void | insert (byte[] key) |
Insert a key. | |
boolean | match (byte[] key) |
Test if the bloom filter matches a particular key. | |
int | size () |
Returns the value given on creation by estimatedMembers. | |
byte[] | seed () |
Get a copy of the seed. | |
long | getElementLabel () |
Gets the type of element this is within an exclude filter. | |
void | decode (XMLDecoder decoder) throws ContentDecodingException |
Decode this object as the top-level item in a new XML document, reading it from a network buffer. | |
void | encode (XMLEncoder encoder) throws ContentEncodingException |
Encode this object during an ongoing encoding pass; this is what subclasses generally need to know how to implement. | |
int | compareTo (BloomFilter o) |
BloomFilter | clone () throws CloneNotSupportedException |
boolean | validate () |
Make sure all of the necessary fields are filled in prior to attempting to encode. | |
int | hashCode () |
boolean | equals (Object obj) |
Static Public Member Functions | |
static byte[] | createSeed () |
Create a seed from random values. |
Implement bloom filter operations.
Bloom filters are used to exclude keys that are inserted into the filter
org.ccnx.ccn.protocol.BloomFilter.BloomFilter | ( | int | estimatedMembers, | |
byte[] | seed | |||
) |
Constructor.
estimatedMembers | The performance of the bloom filter can be improved by accurately estimating the number of members that will be inserted into it. Too low a number will increase the likelihood of false positives. Too high a number will cause the filter to be larger than necessary, impacting performance. It is better for this number to be too low than too high. | |
seed | Random seed data must be of length 4 |
static byte [] org.ccnx.ccn.protocol.BloomFilter.createSeed | ( | ) | [static] |
Create a seed from random values.
void org.ccnx.ccn.protocol.BloomFilter.decode | ( | XMLDecoder | decoder | ) | throws ContentDecodingException [virtual] |
Decode this object as the top-level item in a new XML document, reading it from a network buffer.
Reads document start and end. Assumes default encoding.
buf | input stream to read from |
ContentDecodingException | if there is an error decoding the content Decode this object as the top-level item in a new XML document, reading it from a network buffer. Reads document start and end. |
buf | input stream to read from | |
codec | the codec to use; must be recognized by XMLCodecFactory |
ContentDecodingException | if there is an error decoding the content |
decoder | the decoder being used; encapsulates state including the codec being used as well as the input source and current offset |
Implements org.ccnx.ccn.impl.encoding.GenericXMLEncodable.
void org.ccnx.ccn.protocol.BloomFilter.encode | ( | XMLEncoder | encoder | ) | throws ContentEncodingException [virtual] |
Encode this object during an ongoing encoding pass; this is what subclasses generally need to know how to implement.
Writes just the object itself, higher-level processes have handled start and end document if need be. Allows object to be written using the same code whether it is a top-level element written alone, or nested inside another element.
encoder | the encoder being used; encapsulates state including the codec being used as well as the output destination and current offset |
Implements org.ccnx.ccn.impl.encoding.GenericXMLEncodable.
void org.ccnx.ccn.protocol.BloomFilter.insert | ( | byte[] | key | ) |
Insert a key.
key | a key to exclude |
boolean org.ccnx.ccn.protocol.BloomFilter.match | ( | byte[] | key | ) | [virtual] |
Test if the bloom filter matches a particular key.
Note - a negative result means the key was definitely not set, but a positive result only means the key was likely set.
key | key to test |
Implements org.ccnx.ccn.protocol.Exclude.Filler.
byte [] org.ccnx.ccn.protocol.BloomFilter.seed | ( | ) |
Get a copy of the seed.
int org.ccnx.ccn.protocol.BloomFilter.size | ( | ) |
Returns the value given on creation by estimatedMembers.
boolean org.ccnx.ccn.protocol.BloomFilter.validate | ( | ) | [virtual] |
Make sure all of the necessary fields are filled in prior to attempting to encode.
All implementations of encode(XMLEncoder) should call this for their classes prior to encoding.
Implements org.ccnx.ccn.impl.encoding.GenericXMLEncodable.