java.lang.Object | ||
↳ | org.apache.lucene.search.DocIdSet | |
↳ | org.apache.lucene.util.OpenBitSet |
Known Direct Subclasses |
An "open" BitSet implementation that allows direct access to the array of words storing the bits.
Unlike java.util.bitset, the fact that bits are packed into an array of longs is part of the interface. This allows efficient implementation of other algorithms by someone other than the author. It also allows one to efficiently implement alternate serialization or interchange formats.OpenBitSet
is faster than java.util.BitSet
in most operations
and *much* faster at calculating cardinality of sets and results of set operations.
It can also handle sets of larger cardinality (up to 64 * 2**32-1)
The goals of OpenBitSet
are the fastest implementation possible, and
maximum code reuse. Extra safety and encapsulation
may always be built on top, but if that's built in, the cost can never be removed (and
hence people re-implement their own version in order to get better performance).
If you want a "safe", totally encapsulated (and slower and limited) BitSet
class, use java.util.BitSet
.
cardinality | intersect_count | union | nextSetBit | get | iterator | |
---|---|---|---|---|---|---|
50% full | 3.36 | 3.96 | 1.44 | 1.46 | 1.99 | 1.58 |
1% full | 3.31 | 3.90 | 1.04 | 0.99 |
cardinality | intersect_count | union | nextSetBit | get | iterator | |
---|---|---|---|---|---|---|
50% full | 2.50 | 3.50 | 1.00 | 1.03 | 1.12 | 1.25 |
1% full | 2.51 | 3.49 | 1.00 | 1.02 |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
bits | |||||||||||
wlen |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.lucene.search.DocIdSet
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs an OpenBitSet large enough to hold numBits.
| |||||||||||
Constructs an OpenBitSet from an existing long[].
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the popcount or cardinality of "a and not b"
or "intersection(a, not(b))".
| |||||||||||
returns the number of 64 bit words it would take to hold numBits
| |||||||||||
Returns the current capacity in bits (1 greater than the index of the last bit)
| |||||||||||
Clears a range of bits.
| |||||||||||
clears a bit, allowing access beyond the current set size without changing the size.
| |||||||||||
Clears a range of bits.
| |||||||||||
Ensure that the long[] is big enough to hold numBits, expanding it if necessary.
| |||||||||||
Expand the long[] with the size given as a number of words (64 bit longs).
| |||||||||||
returns true if both sets have the same bits set
| |||||||||||
clears a bit.
| |||||||||||
clears a bit.
| |||||||||||
flips a bit.
| |||||||||||
flips a bit.
| |||||||||||
Returns true or false for the specified bit index.
| |||||||||||
Returns true or false for the specified bit index.
| |||||||||||
Sets the bit at the specified index.
| |||||||||||
Sets the bit at the specified index.
| |||||||||||
flips a bit, expanding the set size if necessary
| |||||||||||
Flips a range of bits, expanding the set size if necessary
| |||||||||||
flips a bit and returns the resulting bit value.
| |||||||||||
flips a bit and returns the resulting bit value.
| |||||||||||
Returns true or false for the specified bit index
| |||||||||||
Returns true or false for the specified bit index.
| |||||||||||
Sets a bit and returns the previous value.
| |||||||||||
Sets a bit and returns the previous value.
| |||||||||||
returns 1 if the bit is set, 0 if not.
| |||||||||||
Expert: returns the long[] storing the bits
| |||||||||||
Expert: gets the number of longs in the array that are in use
| |||||||||||
this = this AND other
| |||||||||||
Returns the popcount or cardinality of the intersection of the two sets.
| |||||||||||
returns true if the sets have any elements in common
| |||||||||||
This DocIdSet implementation is cacheable.
| |||||||||||
Returns true if there are no set bits
| |||||||||||
Provides a
DocIdSetIterator to access the set. | |||||||||||
Returns the index of the first set bit starting at the index specified.
| |||||||||||
Returns the index of the first set bit starting at the index specified.
| |||||||||||
Remove all elements set in other.
| |||||||||||
Sets a range of bits, expanding the set size if necessary
| |||||||||||
sets a bit, expanding the set size if necessary
| |||||||||||
Expert: sets a new long[] to use as the bit storage
| |||||||||||
Expert: sets the number of longs in the array that are in use
| |||||||||||
Returns the current capacity of this set.
| |||||||||||
Lowers numWords, the number of words in use,
by checking for trailing zero words.
| |||||||||||
this = this OR other
| |||||||||||
Returns the popcount or cardinality of the union of the two sets.
| |||||||||||
this = this XOR other
| |||||||||||
Returns the popcount or cardinality of the exclusive-or of the two sets.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.lucene.search.DocIdSet
| |||||||||||
From class
java.lang.Object
|
Constructs an OpenBitSet large enough to hold numBits.
Constructs an OpenBitSet from an existing long[].
The first 64 bits are in long[0],
with bit index 0 at the least significant bit, and bit index 63 at the most significant.
Given a bit index,
the word containing it is long[index/64], and it is at bit number index%64 within that word.
numWords are the number of elements in the array that contain set bits (non-zero longs). numWords should be <= bits.length, and any existing words in the array at position >= numWords should be zero.
Returns the popcount or cardinality of "a and not b" or "intersection(a, not(b))". Neither set is modified.
returns the number of 64 bit words it would take to hold numBits
Returns the current capacity in bits (1 greater than the index of the last bit)
Clears a range of bits. Clearing past the end does not change the size of the set.
startIndex | lower index |
---|---|
endIndex | one-past the last bit to clear |
clears a bit, allowing access beyond the current set size without changing the size.
Clears a range of bits. Clearing past the end does not change the size of the set.
startIndex | lower index |
---|---|
endIndex | one-past the last bit to clear |
Ensure that the long[] is big enough to hold numBits, expanding it if necessary. getNumWords() is unchanged by this call.
Expand the long[] with the size given as a number of words (64 bit longs). getNumWords() is unchanged by this call.
clears a bit. The index should be less than the OpenBitSet size.
clears a bit. The index should be less than the OpenBitSet size.
flips a bit. The index should be less than the OpenBitSet size.
flips a bit. The index should be less than the OpenBitSet size.
Returns true or false for the specified bit index. The index should be less than the OpenBitSet size
Returns true or false for the specified bit index. The index should be less than the OpenBitSet size.
Sets the bit at the specified index. The index should be less than the OpenBitSet size.
Sets the bit at the specified index. The index should be less than the OpenBitSet size.
flips a bit, expanding the set size if necessary
Flips a range of bits, expanding the set size if necessary
startIndex | lower index |
---|---|
endIndex | one-past the last bit to flip |
flips a bit and returns the resulting bit value. The index should be less than the OpenBitSet size.
flips a bit and returns the resulting bit value. The index should be less than the OpenBitSet size.
Returns true or false for the specified bit index
Returns true or false for the specified bit index.
Sets a bit and returns the previous value. The index should be less than the OpenBitSet size.
Sets a bit and returns the previous value. The index should be less than the OpenBitSet size.
returns 1 if the bit is set, 0 if not. The index should be less than the OpenBitSet size
Expert: returns the long[] storing the bits
Expert: gets the number of longs in the array that are in use
Returns the popcount or cardinality of the intersection of the two sets. Neither set is modified.
This DocIdSet implementation is cacheable.
Returns true if there are no set bits
Provides a DocIdSetIterator
to access the set.
This implementation can return null
or
if there
are no docs that match. EMPTY_DOCIDSET
.iterator()
Returns the index of the first set bit starting at the index specified. -1 is returned if there are no more set bits.
Returns the index of the first set bit starting at the index specified. -1 is returned if there are no more set bits.
Sets a range of bits, expanding the set size if necessary
startIndex | lower index |
---|---|
endIndex | one-past the last bit to set |
sets a bit, expanding the set size if necessary
Expert: sets a new long[] to use as the bit storage
Expert: sets the number of longs in the array that are in use
Returns the current capacity of this set. Included for
compatibility. This is *not* equal to cardinality()
Lowers numWords, the number of words in use, by checking for trailing zero words.
Returns the popcount or cardinality of the union of the two sets. Neither set is modified.
Returns the popcount or cardinality of the exclusive-or of the two sets. Neither set is modified.