public class BitDocSet extends DocSetBase
BitDocSet
represents an unordered set of Lucene Document Ids
using a BitSet. A set bit represents inclusion in the set for that document.Modifier and Type | Field and Description |
---|---|
(package private) org.apache.lucene.util.OpenBitSet |
bits |
(package private) int |
size |
Constructor and Description |
---|
BitDocSet() |
BitDocSet(org.apache.lucene.util.OpenBitSet bits)
Construct a BitDocSet.
|
BitDocSet(org.apache.lucene.util.OpenBitSet bits,
int size)
Construct a BitDocSet, and provides the number of set bits.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int doc)
Adds the specified document if it is not currently in the DocSet
(optional operation).
|
void |
addUnique(int doc)
Adds a document the caller knows is not currently in the DocSet
(optional operation).
|
DocSet |
andNot(DocSet other)
Returns the documents in this set that are not in the other set.
|
int |
andNotSize(DocSet other)
Returns the number of documents in this set that are not in the other set.
|
boolean |
exists(int doc)
Returns true if a document is in the DocSet.
|
org.apache.lucene.util.OpenBitSet |
getBits()
Inefficient base implementation.
|
int |
intersectionSize(DocSet other)
Returns the number of documents of the intersection of this set with another set.
|
void |
invalidateSize()
The number of set bits - size - is cached.
|
DocIterator |
iterator()
DocIterator using nextSetBit()
public DocIterator iterator() {
return new DocIterator() {
int pos=bits.nextSetBit(0);
public boolean hasNext() {
return pos>=0;
}
public Integer next() {
return nextDoc();
}
public void remove() {
bits.clear(pos);
}
public int nextDoc() {
int old=pos;
pos=bits.nextSetBit(old+1);
return old;
}
public float score() {
return 0.0f;
}
};
}
|
long |
memSize()
Returns the approximate amount of memory taken by this DocSet.
|
int |
size()
Returns the number of documents in the set.
|
DocSet |
union(DocSet other)
Returns the union of this set with another set.
|
int |
unionSize(DocSet other)
Returns the number of documents of the union of this set with another set.
|
equals, getTopFilter, intersection
public BitDocSet()
public BitDocSet(org.apache.lucene.util.OpenBitSet bits)
public BitDocSet(org.apache.lucene.util.OpenBitSet bits, int size)
public DocIterator iterator()
public org.apache.lucene.util.OpenBitSet getBits()
DocSetBase
getBits
in interface DocSet
getBits
in class DocSetBase
getBits()
public void add(int doc)
DocSet
add
in interface DocSet
add
in class DocSetBase
DocSet.addUnique(int)
public void addUnique(int doc)
DocSet
This method may be faster then add(doc)
in some
implementaions provided the caller is certain of the precondition.
addUnique
in interface DocSet
addUnique
in class DocSetBase
DocSet.add(int)
public int size()
DocSet
public void invalidateSize()
public boolean exists(int doc)
DocSet
public int intersectionSize(DocSet other)
DocSet
intersectionSize
in interface DocSet
intersectionSize
in class DocSetBase
public int unionSize(DocSet other)
DocSet
unionSize
in interface DocSet
unionSize
in class DocSetBase
public int andNotSize(DocSet other)
DocSet
andNotSize
in interface DocSet
andNotSize
in class DocSetBase
public DocSet andNot(DocSet other)
DocSet
andNot
in interface DocSet
andNot
in class DocSetBase
public DocSet union(DocSet other)
DocSet
union
in interface DocSet
union
in class DocSetBase
public long memSize()
DocSet