org.apache.solr.search
Interface DocSet

All Known Subinterfaces:
DocList
All Known Implementing Classes:
BitDocSet, DocSlice, HashDocSet, SortedIntDocSet

public interface DocSet

DocSet represents an unordered set of Lucene Document Ids.

WARNING: Any DocSet returned from SolrIndexSearcher should not be modified as it may have been retrieved from a cache and could be shared.

Since:
solr 0.9

Field Summary
static DocSet EMPTY
           
 
Method Summary
 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 docid)
          Returns true if a document is in the DocSet.
 OpenBitSet getBits()
          Returns a BitSet view of the DocSet.
 Filter getTopFilter()
          Returns a Filter for use in Lucene search methods, assuming this DocSet was generated from the top-level MultiReader that the Lucene search methods will be invoked with.
 DocSet intersection(DocSet other)
          Returns the intersection of this set with another set.
 int intersectionSize(DocSet other)
          Returns the number of documents of the intersection of this set with another set.
 boolean intersects(DocSet other)
          Returns true if these sets have any elements in common
 DocIterator iterator()
          Returns an iterator that may be used to iterate over all of the documents in the set.
 long memSize()
          Returns the approximate amount of memory taken by this DocSet.
 void setBitsOn(OpenBitSet target)
          Takes the docs from this set and sets those bits on the target OpenBitSet.
 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.
 

Field Detail

EMPTY

static final DocSet EMPTY
Method Detail

add

void add(int doc)
Adds the specified document if it is not currently in the DocSet (optional operation).

Throws:
SolrException - if the implementation does not allow modifications
See Also:
addUnique(int)

addUnique

void addUnique(int doc)
Adds a document the caller knows is not currently in the DocSet (optional operation).

This method may be faster then add(doc) in some implementaions provided the caller is certain of the precondition.

Throws:
SolrException - if the implementation does not allow modifications
See Also:
add(int)

size

int size()
Returns the number of documents in the set.


exists

boolean exists(int docid)
Returns true if a document is in the DocSet.


iterator

DocIterator iterator()
Returns an iterator that may be used to iterate over all of the documents in the set.

The order of the documents returned by this iterator is non-deterministic, and any scoring information is meaningless


getBits

OpenBitSet getBits()
Returns a BitSet view of the DocSet. Any changes to this BitSet may be reflected in the DocSet, hence if the DocSet is shared or was returned from a SolrIndexSearcher method, it's not safe to modify the BitSet.

Returns:
An OpenBitSet with the bit number of every docid set in the set.

memSize

long memSize()
Returns the approximate amount of memory taken by this DocSet. This is only an approximation and doesn't take into account java object overhead.

Returns:
the approximate memory consumption in bytes

intersection

DocSet intersection(DocSet other)
Returns the intersection of this set with another set. Neither set is modified - a new DocSet is created and returned.

Returns:
a DocSet representing the intersection

intersectionSize

int intersectionSize(DocSet other)
Returns the number of documents of the intersection of this set with another set. May be more efficient than actually creating the intersection and then getting it's size.


intersects

boolean intersects(DocSet other)
Returns true if these sets have any elements in common


union

DocSet union(DocSet other)
Returns the union of this set with another set. Neither set is modified - a new DocSet is created and returned.

Returns:
a DocSet representing the union

unionSize

int unionSize(DocSet other)
Returns the number of documents of the union of this set with another set. May be more efficient than actually creating the union and then getting it's size.


andNot

DocSet andNot(DocSet other)
Returns the documents in this set that are not in the other set. Neither set is modified - a new DocSet is created and returned.

Returns:
a DocSet representing this AND NOT other

andNotSize

int andNotSize(DocSet other)
Returns the number of documents in this set that are not in the other set.


getTopFilter

Filter getTopFilter()
Returns a Filter for use in Lucene search methods, assuming this DocSet was generated from the top-level MultiReader that the Lucene search methods will be invoked with.


setBitsOn

void setBitsOn(OpenBitSet target)
Takes the docs from this set and sets those bits on the target OpenBitSet. The target should be sized large enough to accommodate all of the documents before calling this method.



Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.