public class KeySelector.GenericBitSelector extends Object implements KeySelector.BitSelector
This implementation uses a 5-bit stride algorithm to extract k bit positions from key data. It's suitable for general values of m (filter size) and k (number of hash functions) within reasonable bounds.
Algorithm overview:
- Processes key data in 5-bit increments
- Uses bit manipulation to extract specific bit positions
- Handles cases where bits span across byte boundaries
- Employs lookup tables (UNMASK/MASK) for efficient bit operations
The 5-bit stride is chosen as it provides good distribution while keeping implementation complexity manageable. Each hash function will examine bits that are 5 positions apart in the key.
Thread Safety: This implementation is thread-safe as it operates only on method parameters and local variables.
| Constructor and Description |
|---|
GenericBitSelector()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
getBitSelectors(byte[] b,
int offset,
int length,
int[] bitOffset)
Extracts k bit offsets from key data using 5-bit stride algorithm.
|
public void getBitSelectors(byte[] b,
int offset,
int length,
int[] bitOffset)
This method processes the key data byte by byte, extracting bit positions at 5-bit intervals. For each bit position, it calculates which byte contains the bit and extracts the appropriate bits using bit masking and shifting operations.
Algorithm details:
- Tracks current bit position across byte boundaries
- Uses UNMASK array to isolate right-aligned bits
- Uses MASK array to isolate left-aligned bits
- Handles cases where bits span multiple bytes
getBitSelectors in interface KeySelector.BitSelectorb - key data as byte arrayoffset - starting position within key arraylength - number of bytes to processbitOffset - output array of length k to store calculated bit offsets