Class BitMaps
int indices into Bloom filter bit positions and visa versa.
The functions view an array of longs as a collection of bit maps each containing 64 bits. The bits are arranged in memory as a little-endian long value. This matches the requirements of the BitMapExtractor interface.
- Since:
- 4.5.0-M2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intA bit shift to apply to an integer to divided by 64 (2^6). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontains(long[] bitMaps, int bitIndex) Checks if the specified index bit is enabled in the array of bit maps.static longgetLongBit(int bitIndex) Gets the filter bit mask for the specified bit index assuming the filter is using 64-bit longs to store bits starting at index 0.static intgetLongIndex(int bitIndex) Gets the filter index for the specified bit index assuming the filter is using 64-bit longs to store bits starting at index 0.static intmod(long dividend, int divisor) Performs a modulus calculation on an unsigned long and a positive integer divisor.(package private) static long[]newBitMap(int numberOfBits) Creates a new bitmap for the number of bit maps (longs) required for the numberOfBits parameter.(package private) static long[]Creates a new bitmap for given shape parameter.static intnumberOfBitMaps(int numberOfBits) Calculates the number of bit maps (longs) required for the numberOfBits parameter.(package private) static intnumberOfBitMaps(Shape shape) Calculates the number of bit maps (longs) required for the shape parameter.static voidset(long[] bitMaps, int bitIndex) Sets the bit in the bit maps.
-
Field Details
-
DIVIDE_BY_64
private static final int DIVIDE_BY_64A bit shift to apply to an integer to divided by 64 (2^6).- See Also:
-
-
Constructor Details
-
BitMaps
private BitMaps()Do not instantiate.
-
-
Method Details
-
contains
public static boolean contains(long[] bitMaps, int bitIndex) Checks if the specified index bit is enabled in the array of bit maps.If the bit specified by bitIndex is not in the bit map false is returned.
- Parameters:
bitMaps- The array of bit maps.bitIndex- the index of the bit to locate.- Returns:
trueif the bit is enabled,falseotherwise.- Throws:
IndexOutOfBoundsException- if bitIndex specifies a bit not in the range being tracked.
-
getLongBit
public static long getLongBit(int bitIndex) Gets the filter bit mask for the specified bit index assuming the filter is using 64-bit longs to store bits starting at index 0. The returned value is alongwith only 1 bit set.The index is assumed to be positive. For a positive index the result will match
1L << (bitIndex % 64).If the input is negative the behavior is not defined.
- Parameters:
bitIndex- the bit index (assumed to be positive)- Returns:
- the filter bit
-
getLongIndex
public static int getLongIndex(int bitIndex) Gets the filter index for the specified bit index assuming the filter is using 64-bit longs to store bits starting at index 0.The index is assumed to be positive. For a positive index the result will match
bitIndex / 64.The divide is performed using bit shifts. If the input is negative the behavior is not defined.
- Parameters:
bitIndex- the bit index (assumed to be positive)- Returns:
- the index of the bit map in an array of bit maps.
-
mod
public static int mod(long dividend, int divisor) Performs a modulus calculation on an unsigned long and a positive integer divisor.This method computes the same result as
Long.remainderUnsigned(long, long)but assumes that the divisor is an integer in the range 1 to 231 - 1 inclusive, that is a strictly positive integer size.If the divisor is negative the behavior is not defined.
- Parameters:
dividend- an unsigned long value to calculate the modulus of.divisor- the divisor for the modulus calculation, must be strictly positive.- Returns:
- the remainder or modulus value.
- Throws:
ArithmeticException- if the divisor is zero- See Also:
-
newBitMap
static long[] newBitMap(int numberOfBits) Creates a new bitmap for the number of bit maps (longs) required for the numberOfBits parameter.If the input is negative the behavior is not defined.
- Parameters:
numberOfBits- the number of bits to store in the array of bit maps.- Returns:
- a new bitmap.
-
newBitMap
Creates a new bitmap for given shape parameter.- Parameters:
shape- the shape.- Returns:
- a new bitmap.
-
numberOfBitMaps
public static int numberOfBitMaps(int numberOfBits) Calculates the number of bit maps (longs) required for the numberOfBits parameter.If the input is negative the behavior is not defined.
- Parameters:
numberOfBits- the number of bits to store in the array of bit maps.- Returns:
- the number of bit maps necessary.
-
numberOfBitMaps
Calculates the number of bit maps (longs) required for the shape parameter.- Parameters:
shape- the shape.- Returns:
- the number of bit maps necessary.
-
set
public static void set(long[] bitMaps, int bitIndex) Sets the bit in the bit maps.Does not perform range checking
- Parameters:
bitMaps- The array of bit maps.bitIndex- the index of the bit to set.- Throws:
IndexOutOfBoundsException- if bitIndex specifies a bit not in the range being tracked.
-