public final class FixedBitSet extends DocIdSet implements Bits
getBits())
long[], accessed with an int index, implementing Bits and
DocIdSet. If you need to manage more than 2.1B bits, use
LongBitSet.| Modifier and Type | Class and Description |
|---|---|
static class |
FixedBitSet.FixedBitSetIterator
A
DocIdSetIterator which iterates over set bits in a
FixedBitSet. |
Bits.MatchAllBits, Bits.MatchNoBitsEMPTY_ARRAY| Constructor and Description |
|---|
FixedBitSet(int numBits) |
FixedBitSet(long[] storedBits,
int numBits) |
| Modifier and Type | Method and Description |
|---|---|
void |
and(DocIdSetIterator iter)
Does in-place AND of the bits provided by the
iterator.
|
void |
and(FixedBitSet other)
this = this AND other
|
void |
andNot(DocIdSetIterator iter)
Does in-place AND NOT of the bits provided by the
iterator.
|
void |
andNot(FixedBitSet other)
this = this AND NOT other
|
static long |
andNotCount(FixedBitSet a,
FixedBitSet b)
Returns the popcount or cardinality of "a and not b" or
"intersection(a, not(b))".
|
Bits |
bits()
Optionally provides a
Bits interface for random access
to matching documents. |
static int |
bits2words(int numBits)
returns the number of 64 bit words it would take to hold numBits
|
int |
cardinality()
Returns number of set bits.
|
void |
clear(int index) |
void |
clear(int startIndex,
int endIndex)
Clears a range of bits.
|
FixedBitSet |
clone() |
static FixedBitSet |
ensureCapacity(FixedBitSet bits,
int numBits)
If the given
FixedBitSet is large enough to hold numBits,
returns the given bits, otherwise returns a new FixedBitSet which
can hold the requested number of bits. |
boolean |
equals(Object o)
returns true if both sets have the same bits set
|
void |
flip(int startIndex,
int endIndex)
Flips a range of bits
|
boolean |
get(int index)
Returns the value of the bit with the specified
index. |
boolean |
getAndClear(int index) |
boolean |
getAndSet(int index) |
long[] |
getBits()
Expert.
|
int |
hashCode() |
static long |
intersectionCount(FixedBitSet a,
FixedBitSet b)
Returns the popcount or cardinality of the intersection of the two sets.
|
boolean |
intersects(FixedBitSet other)
returns true if the sets have any elements in common
|
boolean |
isCacheable()
This DocIdSet implementation is cacheable.
|
DocIdSetIterator |
iterator()
Provides a
DocIdSetIterator to access the set. |
int |
length()
Returns the number of bits in this set
|
int |
nextSetBit(int index)
Returns the index of the first set bit starting at the index specified.
|
void |
or(DocIdSetIterator iter)
Does in-place OR of the bits provided by the
iterator.
|
void |
or(FixedBitSet other)
this = this OR other
|
int |
prevSetBit(int index)
Returns the index of the last set bit before or on the index specified.
|
void |
set(int index) |
void |
set(int startIndex,
int endIndex)
Sets a range of bits
|
static long |
unionCount(FixedBitSet a,
FixedBitSet b)
Returns the popcount or cardinality of the union of the two sets.
|
void |
xor(DocIdSetIterator iter)
Does in-place XOR of the bits provided by the iterator.
|
void |
xor(FixedBitSet other)
this = this XOR other
|
public FixedBitSet(int numBits)
public FixedBitSet(long[] storedBits,
int numBits)
public static FixedBitSet ensureCapacity(FixedBitSet bits, int numBits)
FixedBitSet is large enough to hold numBits,
returns the given bits, otherwise returns a new FixedBitSet which
can hold the requested number of bits.
NOTE: the returned bitset reuses the underlying long[] of
the given bits if possible. Also, calling length() on the
returned bits may return a value greater than numBits.
public static int bits2words(int numBits)
public static long intersectionCount(FixedBitSet a, FixedBitSet b)
public static long unionCount(FixedBitSet a, FixedBitSet b)
public static long andNotCount(FixedBitSet a, FixedBitSet b)
public DocIdSetIterator iterator()
DocIdSetDocIdSetIterator to access the set.
This implementation can return null if there
are no docs that match.public Bits bits()
DocIdSetBits interface for random access
to matching documents.bits in class DocIdSetnull, if this DocIdSet does not support random access.
In contrast to DocIdSet.iterator(), a return value of null
does not imply that no documents match the filter!
The default implementation does not provide random access, so you
only need to implement this method if your DocIdSet can
guarantee random access to every docid in O(1) time without
external disk access (as Bits interface cannot throw
IOException). This is generally true for bit sets
like FixedBitSet, which return
itself if they are used as DocIdSet.public int length()
Bitspublic boolean isCacheable()
isCacheable in class DocIdSetpublic long[] getBits()
public int cardinality()
public boolean get(int index)
Bitsindex.get in interface Bitsindex - index, should be non-negative and < Bits.length().
The result of passing negative or out of bounds values is undefined
by this interface, just don't do it!true if the bit is set, false otherwise.public void set(int index)
public boolean getAndSet(int index)
public void clear(int index)
public boolean getAndClear(int index)
public int nextSetBit(int index)
public int prevSetBit(int index)
public void or(DocIdSetIterator iter) throws IOException
IOExceptionpublic void or(FixedBitSet other)
public void xor(FixedBitSet other)
public void xor(DocIdSetIterator iter) throws IOException
IOExceptionpublic void and(DocIdSetIterator iter) throws IOException
IOExceptionpublic boolean intersects(FixedBitSet other)
public void and(FixedBitSet other)
public void andNot(DocIdSetIterator iter) throws IOException
IOExceptionpublic void andNot(FixedBitSet other)
public void flip(int startIndex,
int endIndex)
startIndex - lower indexendIndex - one-past the last bit to flippublic void set(int startIndex,
int endIndex)
startIndex - lower indexendIndex - one-past the last bit to setpublic void clear(int startIndex,
int endIndex)
startIndex - lower indexendIndex - one-past the last bit to clearpublic FixedBitSet clone()
public boolean equals(Object o)
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.