static final class BloomFilterStrategies.LockFreeBitArray
extends java.lang.Object
We use this instead of java.util.BitSet because we need access to the array of longs and we need compare-and-swap.
Modifier and Type | Field and Description |
---|---|
private LongAddable |
bitCount |
(package private) java.util.concurrent.atomic.AtomicLongArray |
data |
private static int |
LONG_ADDRESSABLE_BITS |
Constructor and Description |
---|
LockFreeBitArray(long bits) |
LockFreeBitArray(long[] data) |
Modifier and Type | Method and Description |
---|---|
(package private) long |
bitCount()
Number of set bits (1s).
|
(package private) long |
bitSize()
Number of bits
|
(package private) BloomFilterStrategies.LockFreeBitArray |
copy() |
boolean |
equals(java.lang.Object o) |
(package private) boolean |
get(long bitIndex) |
int |
hashCode() |
(package private) void |
putAll(BloomFilterStrategies.LockFreeBitArray other)
Combines the two BitArrays using bitwise OR.
|
(package private) boolean |
set(long bitIndex)
Returns true if the bit changed value.
|
static long[] |
toPlainArray(java.util.concurrent.atomic.AtomicLongArray atomicLongArray)
Careful here: if threads are mutating the atomicLongArray while this method is executing, the
final long[] will be a "rolling snapshot" of the state of the bit array.
|
private static final int LONG_ADDRESSABLE_BITS
final java.util.concurrent.atomic.AtomicLongArray data
private final LongAddable bitCount
LockFreeBitArray(long bits)
LockFreeBitArray(long[] data)
boolean set(long bitIndex)
boolean get(long bitIndex)
public static long[] toPlainArray(java.util.concurrent.atomic.AtomicLongArray atomicLongArray)
long bitSize()
long bitCount()
Note that because of concurrent set calls and uses of atomics, this bitCount is a (very) close *estimate* of the actual number of bits set. It's not possible to do better than an estimate without locking. Note that the number, if not exactly accurate, is *always* underestimating, never overestimating.
BloomFilterStrategies.LockFreeBitArray copy()
void putAll(BloomFilterStrategies.LockFreeBitArray other)
NOTE: Because of the use of atomics, if the other LockFreeBitArray is being mutated while this operation is executing, not all of those new 1's may be set in the final state of this LockFreeBitArray. The ONLY guarantee provided is that all the bits that were set in the other LockFreeBitArray at the start of this method will be set in this LockFreeBitArray at the end of this method.
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object