public class BloomSHA1 extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
BloomSHA1.FilterKey
Stores the (opaque) bloom filter offsets for reuse.
|
| Constructor and Description |
|---|
BloomSHA1()
Creates a filter of 2^20 bits with k defaulting to 8.
|
BloomSHA1(int m)
Creates a filter of 2^m bits, with the number of 'hash functions"
k defaulting to 8.
|
BloomSHA1(int m,
int k)
Creates a filter with 2^m bits and k 'hash functions', where
each hash function is portion of the 160-bit SHA1 hash.
|
| Modifier and Type | Method and Description |
|---|---|
int |
capacity()
Returns the number of bits in the filter.
|
void |
clear()
Clears the filter, synchronized.
|
double |
falsePositives()
Calculates the approximate false positive rate for the current number of set members.
|
double |
falsePositives(int n)
Calculates the approximate false positive rate for a given number of set members.
|
BloomSHA1.FilterKey |
getFilterKey(byte[] b,
int offset,
int len)
Get the bloom filter offsets for reuse.
|
void |
insert(byte[] b)
Add a key to the set represented by the filter.
|
void |
insert(byte[] b,
int offset,
int len)
Add a key to the set represented by the filter.
|
void |
locked_insert(BloomSHA1.FilterKey fk)
Add the key to the filter.
|
void |
locked_insert(byte[] b)
Add a key to the filter without synchronization.
|
void |
locked_insert(byte[] b,
int offset,
int len)
Add a key to the filter without synchronization.
|
boolean |
locked_member(BloomSHA1.FilterKey fk)
Is the key in the filter.
|
boolean |
locked_member(byte[] b)
Checks if a key is in the filter without synchronization.
|
boolean |
locked_member(byte[] b,
int offset,
int len)
Checks if a key is in the filter without synchronization.
|
boolean |
member(byte[] b)
Is a key in the filter.
|
boolean |
member(byte[] b,
int offset,
int len)
Is a key in the filter.
|
void |
release(BloomSHA1.FilterKey fk)
Releases filter key arrays back to the buffer pool.
|
int |
size()
Returns the number of keys which have been inserted.
|
public BloomSHA1()
public BloomSHA1(int m)
m - determines size of filterpublic BloomSHA1(int m,
int k)
m - determines number of bits in filterk - number of hash functions
See KeySelector for important restriction on max m and kpublic final int capacity()
public void clear()
public final double falsePositives()
public final double falsePositives(int n)
n - number of set memberspublic BloomSHA1.FilterKey getFilterKey(byte[] b, int offset, int len)
b - byte array representing a key (SHA1 digest)offset - starting offset in the byte arraylen - number of bytes to usepublic void insert(byte[] b)
b - byte array representing a key (SHA1 digest)public void insert(byte[] b,
int offset,
int len)
b - byte array representing a key (SHA1 digest)offset - starting offset in the byte arraylen - number of bytes to usepublic void locked_insert(BloomSHA1.FilterKey fk)
fk - filter key containing offsetspublic final void locked_insert(byte[] b)
b - byte array representing a key (SHA1 digest)public final void locked_insert(byte[] b,
int offset,
int len)
b - byte array representing a key (SHA1 digest)offset - starting offset in the byte arraylen - number of bytes to usepublic boolean locked_member(BloomSHA1.FilterKey fk)
fk - filter key containing offsetspublic final boolean locked_member(byte[] b)
b - byte array representing a key (SHA1 digest)public final boolean locked_member(byte[] b,
int offset,
int len)
b - byte array representing a key (SHA1 digest)offset - starting offset in the byte arraylen - number of bytes to usepublic final boolean member(byte[] b)
b - byte array representing a key (SHA1 digest)public final boolean member(byte[] b,
int offset,
int len)
b - byte array representing a key (SHA1 digest)offset - starting offset in the byte arraylen - number of bytes to usepublic void release(BloomSHA1.FilterKey fk)
fk - filter key to releasepublic final int size()