Package org.xlattice.crypto.filters
Class KeySelector
java.lang.Object
org.xlattice.crypto.filters.KeySelector
Given a key, populates arrays determining word and bit offsets into
a Bloom filter.
- Author:
- Jim Dixon BloomSHA1.java and KeySelector.java are BSD licensed from the xlattice app - http://xlattice.sourceforge.net/ minor tweaks by jrandom, exposing unsynchronized access and allowing larger M and K. changes released into the public domain. As of 0.8.11, bitoffset and wordoffset out parameters moved from fields to selector arguments, to allow concurrency. ALl methods are now thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceclassExtracts the k bit offsets from a key, suitable for general values of m and k.classExtracts the k word offsets from a key.static interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgetOffsets(byte[] key, int[] bitOffset, int[] wordOffset) Given a key, populate the word and bit offset arrays, each of which has k elements.voidgetOffsets(byte[] key, int off, int len, int[] bitOffset, int[] wordOffset) Given a key, populate the word and bit offset arrays, each of which has k elements.
-
Constructor Details
-
KeySelector
public KeySelector(int m, int k) Creates a key selector for a Bloom filter. When a key is presented to the getOffsets() method, the k 'hash function' values are extracted and used to populate bitOffset and wordOffset arrays which specify the k flags to be set or examined in the filter.- Parameters:
m- size of the filter as a power of 2k- number of 'hash functions' Note that if k and m are too big, the GenericWordSelector blows up - The max for 32-byte keys is m=23 and k=11. The precise restriction appears to be: ((5k + (k-1)(m-5)) / 8) + 2 < keySizeInBytes It isn't clear how to fix this.
-
-
Method Details
-
getOffsets
public void getOffsets(byte[] key, int[] bitOffset, int[] wordOffset) Given a key, populate the word and bit offset arrays, each of which has k elements.- Parameters:
key- cryptographic key used in populating the arraysbitOffset- Out parameter of length kwordOffset- Out parameter of length k- Since:
- 0.8.11 out parameters added
-
getOffsets
public void getOffsets(byte[] key, int off, int len, int[] bitOffset, int[] wordOffset) Given a key, populate the word and bit offset arrays, each of which has k elements.- Parameters:
key- cryptographic key used in populating the arraysbitOffset- Out parameter of length kwordOffset- Out parameter of length k- Since:
- 0.8.11 out parameters added
-