it.unimi.di.mg4j.index
Class QuasiSuccinctIndexReader.AbstractQuasiSuccinctIndexIterator

java.lang.Object
  extended by it.unimi.di.mg4j.index.AbstractIndexIterator
      extended by it.unimi.di.mg4j.index.QuasiSuccinctIndexReader.AbstractQuasiSuccinctIndexIterator
All Implemented Interfaces:
IndexIterator, DocumentIterator
Direct Known Subclasses:
QuasiSuccinctIndexReader.EliasFanoIndexIterator, QuasiSuccinctIndexReader.RankedIndexIterator
Enclosing class:
QuasiSuccinctIndexReader

protected abstract static class QuasiSuccinctIndexReader.AbstractQuasiSuccinctIndexIterator
extends AbstractIndexIterator


Field Summary
protected  int count
          The count of the current posting, or -1 if it is not known.
protected  QuasiSuccinctIndexReader.CountReader counts
          The count reader for the current term.
protected  LongBigList countsList
          A reference to the data for counts, or null of hasCounts is false.
protected  int currentDocument
          The current document.
protected  int currentTerm
          The index of the current term.
protected  int frequency
          The frequency of the current term.
protected  boolean hasCounts
          Cached from index.
protected  boolean hasPositions
          Cached from index.
protected  QuasiSuccinctIndex index
          The index of indexReader, cached.
protected  QuasiSuccinctIndexReader indexReader
          The index reader associated to this index iterator.
protected  int nextPosition
          The number of returned positions for the current document.
protected  int numberOfDocuments
          The number of documents (cached from index).
protected  long occurrency
          The occurrency of the current term.
protected  LongBigList pointersList
          A reference to the data for pointers.
protected  QuasiSuccinctIndexReader.LongWordBitReader pointersUpperBits
          A longword bit reader used for the upper bits of pointers and to check whether a posting list is ranked or not.
protected  QuasiSuccinctIndexReader.PositionReader positions
          The position reader for the current term.
protected  LongBigList positionsList
          A reference to the data for positions, or null of hasPositions is false.
 
Fields inherited from class it.unimi.di.mg4j.index.AbstractIndexIterator
id, term, weight
 
Fields inherited from interface it.unimi.di.mg4j.index.IndexIterator
END_OF_POSITIONS
 
Fields inherited from interface it.unimi.di.mg4j.search.DocumentIterator
END_OF_LIST
 
Constructor Summary
protected QuasiSuccinctIndexReader.AbstractQuasiSuccinctIndexIterator(QuasiSuccinctIndexReader indexReader)
           
 
Method Summary
 void dispose()
          Disposes this document iterator, releasing all resources.
 int document()
          Returns the last document returned by DocumentIterator.nextDocument().
 int frequency()
          Returns the frequency, that is, the number of documents that will be returned by this iterator.
 Index index()
          Returns the index over which this iterator is built.
 ReferenceSet<Index> indices()
          Returns the set of indices over which this iterator is built.
 IntervalIterator intervalIterator()
          Returns the interval iterator of this document iterator for single-index queries.
 IntervalIterator intervalIterator(Index index)
          Returns the interval iterator of this document iterator for the given index.
 Reference2ReferenceMap<Index,IntervalIterator> intervalIterators()
          Returns an unmodifiable map from indices to interval iterators.
 int nextPosition()
          Returns the next position at which the term appears in the current document.
 Payload payload()
          Returns the payload, if any, associated with the current document.
protected  boolean ranked(int term)
           
 int termNumber()
          Returns the number of the term whose inverted list is returned by this index iterator.
 String toString()
           
 
Methods inherited from class it.unimi.di.mg4j.index.AbstractIndexIterator
accept, acceptOnTruePaths, id, id, term, term, weight, weight
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.di.mg4j.index.IndexIterator
count
 
Methods inherited from interface it.unimi.di.mg4j.search.DocumentIterator
mayHaveNext, nextDocument, skipTo
 

Field Detail

indexReader

protected final QuasiSuccinctIndexReader indexReader
The index reader associated to this index iterator.


index

protected final QuasiSuccinctIndex index
The index of indexReader, cached.


pointersList

protected final LongBigList pointersList
A reference to the data for pointers.


countsList

protected final LongBigList countsList
A reference to the data for counts, or null of hasCounts is false.


positionsList

protected final LongBigList positionsList
A reference to the data for positions, or null of hasPositions is false.


pointersUpperBits

protected final QuasiSuccinctIndexReader.LongWordBitReader pointersUpperBits
A longword bit reader used for the upper bits of pointers and to check whether a posting list is ranked or not.


counts

protected QuasiSuccinctIndexReader.CountReader counts
The count reader for the current term.


positions

protected QuasiSuccinctIndexReader.PositionReader positions
The position reader for the current term.


numberOfDocuments

protected final int numberOfDocuments
The number of documents (cached from index).


hasCounts

protected final boolean hasCounts
Cached from index.


hasPositions

protected final boolean hasPositions
Cached from index.


currentDocument

protected int currentDocument
The current document.


frequency

protected int frequency
The frequency of the current term.


occurrency

protected long occurrency
The occurrency of the current term.


currentTerm

protected int currentTerm
The index of the current term.


count

protected int count
The count of the current posting, or -1 if it is not known.


nextPosition

protected int nextPosition
The number of returned positions for the current document.

Constructor Detail

QuasiSuccinctIndexReader.AbstractQuasiSuccinctIndexIterator

protected QuasiSuccinctIndexReader.AbstractQuasiSuccinctIndexIterator(QuasiSuccinctIndexReader indexReader)
Method Detail

ranked

protected boolean ranked(int term)

index

public Index index()
Description copied from interface: IndexIterator
Returns the index over which this iterator is built.

Returns:
the index over which this iterator is built.

termNumber

public int termNumber()
Description copied from interface: IndexIterator
Returns the number of the term whose inverted list is returned by this index iterator.

Usually, the term number is automatically set by IndexReader.documents(CharSequence) or IndexReader.documents(int).

Returns:
the number of the term over which this iterator is built.
See Also:
IndexIterator.term()

frequency

public int frequency()
              throws IOException
Description copied from interface: IndexIterator
Returns the frequency, that is, the number of documents that will be returned by this iterator.

Returns:
the number of documents that will be returned by this iterator.
Throws:
IOException

payload

public Payload payload()
                throws IOException
Description copied from interface: IndexIterator
Returns the payload, if any, associated with the current document.

Returns:
the payload associated with the current document.
Throws:
IOException

nextPosition

public int nextPosition()
                 throws IOException
Description copied from interface: IndexIterator
Returns the next position at which the term appears in the current document.

Returns:
the next position of the current document in which the current term appears, or IndexIterator.END_OF_POSITIONS if there are no more positions.
Throws:
IOException

document

public int document()
Description copied from interface: DocumentIterator
Returns the last document returned by DocumentIterator.nextDocument().

Returns:
the last document returned by DocumentIterator.nextDocument(), -1 if no document has been returned yet, and DocumentIterator.END_OF_LIST if the list of results has been exhausted.

intervalIterators

public Reference2ReferenceMap<Index,IntervalIterator> intervalIterators()
                                                                 throws IOException
Description copied from interface: DocumentIterator
Returns an unmodifiable map from indices to interval iterators.

After a call to DocumentIterator.nextDocument(), this map can be used to retrieve the intervals in the current document. An invocation of Map.get(java.lang.Object) on this map with argument index yields the same result as intervalIterator(index).

Returns:
a map from indices to interval iterators over the current document.
Throws:
IOException
See Also:
DocumentIterator.intervalIterator(Index)

intervalIterator

public IntervalIterator intervalIterator()
                                  throws IOException
Description copied from interface: DocumentIterator
Returns the interval iterator of this document iterator for single-index queries.

This is a commodity method that can be used only for queries built over a single index.

Returns:
an interval iterator.
Throws:
IOException
See Also:
DocumentIterator.intervalIterator(Index)

intervalIterator

public IntervalIterator intervalIterator(Index index)
                                  throws IOException
Description copied from interface: DocumentIterator
Returns the interval iterator of this document iterator for the given index.

After a call to DocumentIterator.nextDocument(), this iterator can be used to retrieve the intervals in the current document (the one returned by DocumentIterator.nextDocument()) for the index index.

Note that if all indices have positions, it is guaranteed that at least one index will return an interval. However, for disjunctive queries it cannot be guaranteed that all indices will return an interval.

Indices without positions always return IntervalIterators.TRUE. Thus, in presence of indices without positions it is possible that no intervals at all are available.

Parameters:
index - an index (must be one over which the query was built).
Returns:
an interval iterator over the current document in index.
Throws:
IOException

indices

public ReferenceSet<Index> indices()
Description copied from interface: DocumentIterator
Returns the set of indices over which this iterator is built.

Returns:
the set of indices over which this iterator is built.

toString

public String toString()
Overrides:
toString in class Object

dispose

public void dispose()
             throws IOException
Description copied from interface: DocumentIterator
Disposes this document iterator, releasing all resources.

This method should propagate down to the underlying index iterators, where it should release resources such as open files and network connections. If you're doing your own resource tracking and pooling, then you do not need to call this method.

Throws:
IOException