org.archive.util
Interface BloomFilter

All Known Implementing Classes:
BloomFilter64bit

public interface BloomFilter

Common interface for different Bloom filter implementations

Author:
Gordon Mohr

Method Summary
 boolean add(java.lang.CharSequence s)
          Adds a character sequence to the filter.
 boolean contains(java.lang.CharSequence s)
          Checks whether the given character sequence is in this filter.
 boolean getBit(long bitIndex)
           
 long getExpectedInserts()
          Report the number of expected inserts used at instantiation time to calculate the bitfield size.
 long getHashCount()
          Report the number of internal independent hash function (and thus the number of bits set/checked for each item presented).
 long getSizeBytes()
          The amount of memory in bytes consumed by the bloom bitfield.
 int size()
          The number of character sequences in the filter (considered to be the number of add()s that returned 'true')
 

Method Detail

size

int size()
The number of character sequences in the filter (considered to be the number of add()s that returned 'true')

Returns:
the number of character sequences in the filter (but see contains(CharSequence)).

contains

boolean contains(java.lang.CharSequence s)
Checks whether the given character sequence is in this filter.

Note that this method may return true on a character sequence that is has not been added to the filter. This will happen with probability 2-d, where d is the number of hash functions specified at creation time, if the number of the elements in the filter is less than n, the number of expected elements specified at creation time.

Parameters:
s - a character sequence.
Returns:
true if the sequence is in the filter (or if a sequence with the same hash sequence is in the filter).

add

boolean add(java.lang.CharSequence s)
Adds a character sequence to the filter.

Parameters:
s - a character sequence.
Returns:
true if the character sequence was not in the filter (but see contains(CharSequence)).

getSizeBytes

long getSizeBytes()
The amount of memory in bytes consumed by the bloom bitfield.

Returns:
memory used by bloom bitfield, in bytes

getExpectedInserts

long getExpectedInserts()
Report the number of expected inserts used at instantiation time to calculate the bitfield size.

Returns:
long number of inserts expected at instantiation

getHashCount

long getHashCount()
Report the number of internal independent hash function (and thus the number of bits set/checked for each item presented).

Returns:
long count of hash functions

getBit

boolean getBit(long bitIndex)


Copyright © 2003-2011 Internet Archive. All Rights Reserved.