Class BitStreamIndexReader.BitStreamIndexReaderIndexIterator
- java.lang.Object
-
- it.unimi.di.big.mg4j.index.AbstractIndexIterator
-
- it.unimi.di.big.mg4j.index.BitStreamIndexReader.BitStreamIndexReaderIndexIterator
-
- All Implemented Interfaces:
IndexIterator,DocumentIterator
- Enclosing class:
- BitStreamIndexReader
protected static final class BitStreamIndexReader.BitStreamIndexReaderIndexIterator extends AbstractIndexIterator implements IndexIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected intbThe parameterbfor Golomb coding of pointers.protected intcountThe current count (if this index contains counts).protected CompressionFlags.CodingcountCodingThe cached copy ofindex.countCoding.protected longcurrentDocumentThe last document pointer we read from current list, -1 if we just read the frequency,DocumentIterator.END_OF_LISTif we are beyond the end of list.protected intcurrentPositionThe index of the next position to be returned bynextPosition().protected longcurrentTermThe current term.protected longfrequencyThe current frequency.protected booleanhasCountsThe cached copy ofindex.hasCounts.protected booleanhasPayloadsThe cached copy ofindex.hasPayloads.protected booleanhasPointersWhether the current terms has pointers at all (this happens when thefrequencyis smaller than the number of documents).protected booleanhasPositionsThe cached copy ofindex.hasPositions.protected booleanhasSkipsWhether the underlying index has skips.intheightThe parameterh(the maximum height of a skip tower).protected InputBitStreamibsThe underlying input bit stream.protected BitStreamIndexindexThe reference index.protected intlog2bThe parameterlog2bfor Golomb coding of pointers; it is the most significant bit ofb.protected longnumberOfDocumentRecordThe number of the document record we are going to read inside the current inverted list.protected PayloadpayloadThe payload, in case the index of this reader has payloads, ornull.protected CompressionFlags.CodingpointerCodingThe cached copy ofindex.pointerCoding.protected int[]positionCacheThe cached position array.protected CompressionFlags.CodingpositionCodingThe cached copy ofindex.positionCoding.longquantumThe quantum.intquantumDivisionShiftThe shift giving result of the division byquantum.longquantumModuloMaskThe bit mask giving the remainder of the division byquantum.protected intstateThis variable tracks the current state of the reader.-
Fields inherited from class it.unimi.di.big.mg4j.index.AbstractIndexIterator
id, term, weight
-
Fields inherited from interface it.unimi.di.big.mg4j.search.DocumentIterator
END_OF_LIST
-
Fields inherited from interface it.unimi.di.big.mg4j.index.IndexIterator
END_OF_POSITIONS
-
-
Constructor Summary
Constructors Constructor Description BitStreamIndexReaderIndexIterator(BitStreamIndexReader parent, InputBitStream ibs)
-
Method Summary
Modifier and Type Method Description protected IndexIteratoradvance()intcount()Returns the count, that is, the number of occurrences of the term in the current document.voiddispose()Disposes this document iterator, releasing all resources.longdocument()Returns the last document returned byDocumentIterator.nextDocument().longfrequency()Returns the frequency, that is, the number of documents that will be returned by this iterator.Indexindex()Returns the index over which this iterator is built.ReferenceSet<Index>indices()Returns the set of indices over which this iterator is built.IntervalIteratorintervalIterator()Returns the interval iterator of this document iterator for single-index queries.IntervalIteratorintervalIterator(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.booleanmayHaveNext()Returns whether there may be a next document, possibly with false positives.longnextDocument()Returns the next document provided by this document iterator, orDocumentIterator.END_OF_LISTif no more documents are available.intnextPosition()Returns the next position at which the term appears in the current document.Payloadpayload()Returns the payload, if any, associated with the current document.protected voidposition(long term)Positions the index on the inverted list of a given term.longskipTo(long p)Skips all documents smaller thann.longtermNumber()Returns the number of the term whose inverted list is returned by this index iterator.StringtoString()protected voidupdatePositionCache()We read positions, assuming state <= BEFORE_POSITIONS-
Methods inherited from class it.unimi.di.big.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.big.mg4j.search.DocumentIterator
accept, acceptOnTruePaths, weight
-
-
-
-
Field Detail
-
index
protected final BitStreamIndex index
The reference index.
-
ibs
protected final InputBitStream ibs
The underlying input bit stream.
-
hasPositions
protected final boolean hasPositions
The cached copy ofindex.hasPositions.
-
hasCounts
protected final boolean hasCounts
The cached copy ofindex.hasCounts.
-
hasPayloads
protected final boolean hasPayloads
The cached copy ofindex.hasPayloads.
-
hasSkips
protected final boolean hasSkips
Whether the underlying index has skips.
-
pointerCoding
protected final CompressionFlags.Coding pointerCoding
The cached copy ofindex.pointerCoding.
-
countCoding
protected final CompressionFlags.Coding countCoding
The cached copy ofindex.countCoding.
-
positionCoding
protected final CompressionFlags.Coding positionCoding
The cached copy ofindex.positionCoding.
-
payload
protected final Payload payload
The payload, in case the index of this reader has payloads, ornull.
-
b
protected int b
The parameterbfor Golomb coding of pointers.
-
log2b
protected int log2b
The parameterlog2bfor Golomb coding of pointers; it is the most significant bit ofb.
-
currentTerm
protected long currentTerm
The current term.
-
frequency
protected long frequency
The current frequency.
-
hasPointers
protected boolean hasPointers
Whether the current terms has pointers at all (this happens when thefrequencyis smaller than the number of documents).
-
count
protected int count
The current count (if this index contains counts).
-
currentDocument
protected long currentDocument
The last document pointer we read from current list, -1 if we just read the frequency,DocumentIterator.END_OF_LISTif we are beyond the end of list.
-
numberOfDocumentRecord
protected long numberOfDocumentRecord
The number of the document record we are going to read inside the current inverted list.
-
state
protected int state
This variable tracks the current state of the reader.
-
height
public final int height
The parameterh(the maximum height of a skip tower).
-
quantum
public long quantum
The quantum.
-
quantumModuloMask
public long quantumModuloMask
The bit mask giving the remainder of the division byquantum.
-
quantumDivisionShift
public int quantumDivisionShift
The shift giving result of the division byquantum.
-
currentPosition
protected int currentPosition
The index of the next position to be returned bynextPosition().
-
positionCache
protected int[] positionCache
The cached position array.
-
-
Constructor Detail
-
BitStreamIndexReaderIndexIterator
public BitStreamIndexReaderIndexIterator(BitStreamIndexReader parent, InputBitStream ibs)
-
-
Method Detail
-
position
protected void position(long term) throws IOExceptionPositions the index on the inverted list of a given term.This method can be called at any time. Note that it is always possible to call this method with argument 0, even if offsets have not been loaded.
- Parameters:
term- a term.- Throws:
IOException
-
termNumber
public long termNumber()
Description copied from interface:IndexIteratorReturns 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)orIndexReader.documents(long).- Specified by:
termNumberin interfaceIndexIterator- Returns:
- the number of the term over which this iterator is built.
- See Also:
IndexIterator.term()
-
advance
protected IndexIterator advance() throws IOException
- Throws:
IOException
-
index
public Index index()
Description copied from interface:IndexIteratorReturns the index over which this iterator is built.- Specified by:
indexin interfaceIndexIterator- Returns:
- the index over which this iterator is built.
-
frequency
public long frequency()
Description copied from interface:IndexIteratorReturns the frequency, that is, the number of documents that will be returned by this iterator.- Specified by:
frequencyin interfaceIndexIterator- Returns:
- the number of documents that will be returned by this iterator.
-
document
public long document()
Description copied from interface:DocumentIteratorReturns the last document returned byDocumentIterator.nextDocument().- Specified by:
documentin interfaceDocumentIterator- Returns:
- the last document returned by
DocumentIterator.nextDocument(), -1 if no document has been returned yet, andDocumentIterator.END_OF_LISTif the list of results has been exhausted.
-
payload
public Payload payload() throws IOException
Description copied from interface:IndexIteratorReturns the payload, if any, associated with the current document.- Specified by:
payloadin interfaceIndexIterator- Returns:
- the payload associated with the current document.
- Throws:
IOException
-
count
public int count() throws IOExceptionDescription copied from interface:IndexIteratorReturns the count, that is, the number of occurrences of the term in the current document.- Specified by:
countin interfaceIndexIterator- Returns:
- the count (number of occurrences) of the term in the current document.
- Throws:
IOException
-
updatePositionCache
protected void updatePositionCache() throws IOExceptionWe read positions, assuming state <= BEFORE_POSITIONS- Throws:
IOException
-
nextPosition
public int nextPosition() throws IOExceptionDescription copied from interface:IndexIteratorReturns the next position at which the term appears in the current document.- Specified by:
nextPositionin interfaceIndexIterator- Returns:
- the next position of the current document in which the current term appears,
or
IndexIterator.END_OF_POSITIONSif there are no more positions. - Throws:
IOException
-
nextDocument
public long nextDocument() throws IOExceptionDescription copied from interface:DocumentIteratorReturns the next document provided by this document iterator, orDocumentIterator.END_OF_LISTif no more documents are available.- Specified by:
nextDocumentin interfaceDocumentIterator- Returns:
- the next document, or
DocumentIterator.END_OF_LISTif no more documents are available. - Throws:
IOException
-
skipTo
public long skipTo(long p) throws IOExceptionDescription copied from interface:DocumentIteratorSkips all documents smaller thann.Define the current document
kassociated with this document iterator as follows:- -1, if
DocumentIterator.nextDocument()and this method have never been called; DocumentIterator.END_OF_LIST, if a call to this method or toDocumentIterator.nextDocument()returnedDocumentIterator.END_OF_LIST;- the last value returned by a call to
DocumentIterator.nextDocument()or this method, otherwise.
If
kis larger than or equal ton, then this method does nothing and returnsk. Otherwise, a call to this method is equivalent towhile( ( k = nextDocument() ) < n ); return k;
Thus, when a result
k≠DocumentIterator.END_OF_LISTis returned, the state of this iterator will be exactly the same as after a call toDocumentIterator.nextDocument()that returnedk. In particular, the first document larger than or equal ton(when returned by this method) will not be returned by the next call toDocumentIterator.nextDocument().- Specified by:
skipToin interfaceDocumentIterator- Parameters:
p- a document pointer.- Returns:
- a document pointer larger than or equal to
nif available,DocumentIterator.END_OF_LISTotherwise. - Throws:
IOException
- -1, if
-
dispose
public void dispose() throws IOExceptionDescription copied from interface:DocumentIteratorDisposes 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.
- Specified by:
disposein interfaceDocumentIterator- Throws:
IOException
-
mayHaveNext
public boolean mayHaveNext()
Description copied from interface:DocumentIteratorReturns whether there may be a next document, possibly with false positives.- Specified by:
mayHaveNextin interfaceDocumentIterator- Returns:
- true there may be a next document; false if certainly there is no next document.
-
intervalIterators
public Reference2ReferenceMap<Index,IntervalIterator> intervalIterators() throws IOException
Description copied from interface:DocumentIteratorReturns 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 ofMap.get(java.lang.Object)on this map with argumentindexyields the same result asintervalIterator(index).- Specified by:
intervalIteratorsin interfaceDocumentIterator- 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:DocumentIteratorReturns 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.
- Specified by:
intervalIteratorin interfaceDocumentIterator- Returns:
- an interval iterator.
- Throws:
IOException- See Also:
DocumentIterator.intervalIterator(Index)
-
intervalIterator
public IntervalIterator intervalIterator(Index index) throws IOException
Description copied from interface:DocumentIteratorReturns 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 byDocumentIterator.nextDocument()) for the indexindex.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.- Specified by:
intervalIteratorin interfaceDocumentIterator- 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:DocumentIteratorReturns the set of indices over which this iterator is built.- Specified by:
indicesin interfaceDocumentIterator- Returns:
- the set of indices over which this iterator is built.
-
-