Class AbstractUnionDocumentIterator
- java.lang.Object
-
- it.unimi.di.big.mg4j.search.AbstractDocumentIterator
-
- it.unimi.di.big.mg4j.search.AbstractIntervalDocumentIterator
-
- it.unimi.di.big.mg4j.search.AbstractCompositeDocumentIterator
-
- it.unimi.di.big.mg4j.search.AbstractUnionDocumentIterator
-
- All Implemented Interfaces:
DocumentIterator
- Direct Known Subclasses:
MultiTermIndexIterator
,OrDocumentIterator
public abstract class AbstractUnionDocumentIterator extends AbstractCompositeDocumentIterator
A document iterator computing the union of the documents returned by a number of document iterators.This class provides a mechanism that makes accessible the set of component document iterators that are positioned on the current document.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractUnionDocumentIterator.IntHeapSemiIndirectPriorityQueue
protected static class
AbstractUnionDocumentIterator.LongHeapSemiIndirectPriorityQueue
-
Nested classes/interfaces inherited from class it.unimi.di.big.mg4j.search.AbstractCompositeDocumentIterator
AbstractCompositeDocumentIterator.AbstractCompositeIndexIntervalIterator, AbstractCompositeDocumentIterator.AbstractCompositeIntervalIterator
-
-
Field Summary
Fields Modifier and Type Field Description int[]
front
protected int
frontSize
The number of valid entries infront
, or 0 if the front has not been computed for the current document.protected AbstractUnionDocumentIterator.LongHeapSemiIndirectPriorityQueue
queue
A heap-based semi-indirect priority queue used to keep track of the currently scanned integers.protected long[]
refArray
The reference array used for the queue.-
Fields inherited from class it.unimi.di.big.mg4j.search.AbstractCompositeDocumentIterator
documentIterator, indexIterator, indexIteratorsWithoutPositions, n
-
Fields inherited from class it.unimi.di.big.mg4j.search.AbstractIntervalDocumentIterator
currentIterators, indices, intervalIterators, soleIndex, soleIntervalIterator, unmodifiableCurrentIterators
-
Fields inherited from class it.unimi.di.big.mg4j.search.AbstractDocumentIterator
curr, weight
-
Fields inherited from interface it.unimi.di.big.mg4j.search.DocumentIterator
END_OF_LIST
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractUnionDocumentIterator(DocumentIterator... documentIterator)
-
Method Summary
Modifier and Type Method Description <T> T
acceptOnTruePaths(DocumentIteratorVisitor<T> visitor)
InvokesacceptOnTruePaths(DocumentIteratorVisitor)
only on component iterators positioned on the current document.int
computeFront()
Forces computation of the current front, returning the number of indices it contains.Reference2ReferenceMap<Index,IntervalIterator>
intervalIterators()
Returns an unmodifiable map from indices to interval iterators.long
nextDocument()
Returns the next document provided by this document iterator, orDocumentIterator.END_OF_LIST
if no more documents are available.long
skipTo(long n)
Skips all documents smaller thann
.-
Methods inherited from class it.unimi.di.big.mg4j.search.AbstractCompositeDocumentIterator
accept, dispose, toString
-
Methods inherited from class it.unimi.di.big.mg4j.search.AbstractIntervalDocumentIterator
allIndexIterators, getIntervalIterator, indices, indices
-
Methods inherited from class it.unimi.di.big.mg4j.search.AbstractDocumentIterator
document, ensureOnADocument, mayHaveNext, 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
document, indices, intervalIterator, intervalIterator, mayHaveNext, weight, weight
-
-
-
-
Field Detail
-
queue
protected final AbstractUnionDocumentIterator.LongHeapSemiIndirectPriorityQueue queue
A heap-based semi-indirect priority queue used to keep track of the currently scanned integers.
-
front
public final int[] front
-
refArray
protected final long[] refArray
The reference array used for the queue.
-
frontSize
protected int frontSize
The number of valid entries infront
, or 0 if the front has not been computed for the current document.
-
-
Constructor Detail
-
AbstractUnionDocumentIterator
protected AbstractUnionDocumentIterator(DocumentIterator... documentIterator)
-
-
Method Detail
-
skipTo
public long skipTo(long n) throws IOException
Description copied from interface:DocumentIterator
Skips all documents smaller thann
.Define the current document
k
associated 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
k
is 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_LIST
is 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()
.- Parameters:
n
- a document pointer.- Returns:
- a document pointer larger than or equal to
n
if available,DocumentIterator.END_OF_LIST
otherwise. - Throws:
IOException
- -1, if
-
nextDocument
public long nextDocument() throws IOException
Description copied from interface:DocumentIterator
Returns the next document provided by this document iterator, orDocumentIterator.END_OF_LIST
if no more documents are available.- Returns:
- the next document, or
DocumentIterator.END_OF_LIST
if no more documents are available. - Throws:
IOException
-
computeFront
public int computeFront()
Forces computation of the current front, returning the number of indices it contains.After a call to this method, the first elements of
front
contain the indices of the component document iterators that are positioned on the current document. If the front has already been computed for the current document, this method has no side effects.- Returns:
- the size of the current front (the number of valid entries in
front
).
-
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 ofMap.get(java.lang.Object)
on this map with argumentindex
yields the same result asintervalIterator(index)
.- Returns:
- a map from indices to interval iterators over the current document.
- Throws:
IOException
- See Also:
DocumentIterator.intervalIterator(Index)
-
acceptOnTruePaths
public <T> T acceptOnTruePaths(DocumentIteratorVisitor<T> visitor) throws IOException
InvokesacceptOnTruePaths(DocumentIteratorVisitor)
only on component iterators positioned on the current document.- Specified by:
acceptOnTruePaths
in interfaceDocumentIterator
- Overrides:
acceptOnTruePaths
in classAbstractCompositeDocumentIterator
- Parameters:
visitor
- a visitor.- Returns:
- true if the visit should continue.
- Throws:
IOException
- See Also:
DocumentIterator.accept(DocumentIteratorVisitor)
,CounterCollectionVisitor
-
-