org.xlattice.crypto.filters
public class BloomSHA1 extends Object
Modifier and Type | Field and Description |
---|---|
protected int[] |
bitOffset |
protected int |
count |
protected int[] |
filter |
protected int |
filterBits |
protected int |
filterWords |
protected int |
k |
protected KeySelector |
ks |
protected int |
m |
protected int[] |
wordOffset |
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 |
---|---|
static String |
btoh(byte b)
convert single byte to String
|
int |
capacity() |
void |
clear()
Synchronized version
|
protected void |
doClear()
Clear the filter, unsynchronized
|
double |
falsePositives() |
double |
falsePositives(int n) |
void |
insert(byte[] b)
Add a key to the set represented by the filter.
|
void |
insert(byte[] b,
int offset,
int len) |
protected boolean |
isMember(byte[] b)
Is a key in the filter.
|
protected boolean |
isMember(byte[] b,
int offset,
int len) |
static String |
itoh(int i)
convert 32-bit integer to String
|
static String |
keyToString(byte[] key) |
void |
locked_insert(byte[] b) |
void |
locked_insert(byte[] b,
int offset,
int len) |
boolean |
locked_member(byte[] b) |
boolean |
locked_member(byte[] b,
int offset,
int len) |
static String |
ltoh(long i)
convert 64-bit integer to hex String
|
boolean |
member(byte[] b)
Is a key in the filter.
|
boolean |
member(byte[] b,
int offset,
int len) |
int |
size()
Returns the number of keys which have been inserted.
|
protected final int m
protected final int k
protected int count
protected final int[] filter
protected KeySelector ks
protected final int[] wordOffset
protected final int[] bitOffset
protected final int filterBits
protected final int filterWords
public BloomSHA1(int m, int k)
m
- determines number of bits in filterk
- number of hash functionsx
See KeySelector for important restriction on max m and kpublic BloomSHA1(int m)
m
- determines size of filterpublic BloomSHA1()
protected void doClear()
public void clear()
public final int size()
public final int capacity()
public void insert(byte[] b)
b
- byte array representing a key (SHA1 digest)public void insert(byte[] b, int offset, int len)
public final void locked_insert(byte[] b)
public final void locked_insert(byte[] b, int offset, int len)
protected final boolean isMember(byte[] b)
b
- byte array representing a key (SHA1 digest)protected final boolean isMember(byte[] b, int offset, int len)
public final boolean locked_member(byte[] b)
public final boolean locked_member(byte[] b, int offset, int len)
public final boolean member(byte[] b)
b
- byte array representing a key (SHA1 digest)public final boolean member(byte[] b, int offset, int len)
public final double falsePositives(int n)
n
- number of set memberspublic final double falsePositives()
public static String keyToString(byte[] key)
public static String ltoh(long i)
public static String itoh(int i)
public static String btoh(byte b)