Package it.unimi.di.big.mg4j.search
Class AbstractIntervalDocumentIterator
- java.lang.Object
-
- it.unimi.di.big.mg4j.search.AbstractDocumentIterator
-
- it.unimi.di.big.mg4j.search.AbstractIntervalDocumentIterator
-
- All Implemented Interfaces:
DocumentIterator
- Direct Known Subclasses:
AbstractCompositeDocumentIterator
,AlignDocumentIterator
,AnnotationDocumentIterator
,ContainmentDocumentIterator
,DifferenceDocumentIterator
,InclusionDocumentIterator
,LowPassDocumentIterator
public abstract class AbstractIntervalDocumentIterator extends AbstractDocumentIterator
An abstract iterator on documents that provides basic support for handling interval iterators.Implementing subclasses must override
getIntervalIterator(Index, int, boolean, Object)
so that it returns the correct interval iterator. Note that because of delays in class initialization, the constructor of this class takes a number of apparently disparate parameters: they are necessary to initialize various kinds of interval iterators. This class provides static methods that help in building the correct value for the parameters of the constructor.
-
-
Field Summary
Fields Modifier and Type Field Description protected Index2IntervalIteratorMap
currentIterators
A map from indices to the iterators returned for the current document.protected ReferenceSet<Index>
indices
The set of indices involved in this iterator.protected Index2IntervalIteratorMap
intervalIterators
A map from indices to interval iterators.protected Index
soleIndex
If notnull
, the sole index involved in this document iterator.protected IntervalIterator
soleIntervalIterator
If notnull
, the sole interval iterator involved in this document iterator.protected Reference2ReferenceMap<Index,IntervalIterator>
unmodifiableCurrentIterators
An unmodifiable wrapper aroundcurrentIterators
.-
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
AbstractIntervalDocumentIterator(int n, ReferenceSet<Index> indices, boolean allIndexIterators, Object arg)
Creates a new instance.
-
Method Summary
Modifier and Type Method Description protected static boolean
allIndexIterators(DocumentIterator... documentIterator)
A commodity static methods that checks whether all specified document iterators are actually index iterators.protected abstract IntervalIterator
getIntervalIterator(Index index, int n, boolean allIndexIterators, Object arg)
Creates an interval iterator suitable for thisAbstractIntervalDocumentIterator
.ReferenceSet<Index>
indices()
Returns the set of indices over which this iterator is built.protected static ReferenceArraySet<Index>
indices(Index index, DocumentIterator... documentIterator)
A commodity static methods that computes the union of the indices of the given document iterators.-
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, toString, wait, wait, wait
-
Methods inherited from interface it.unimi.di.big.mg4j.search.DocumentIterator
accept, acceptOnTruePaths, dispose, intervalIterator, intervalIterator, intervalIterators, nextDocument, skipTo
-
-
-
-
Field Detail
-
indices
protected final ReferenceSet<Index> indices
The set of indices involved in this iterator.
-
soleIndex
protected final Index soleIndex
If notnull
, the sole index involved in this document iterator.
-
soleIntervalIterator
protected final IntervalIterator soleIntervalIterator
If notnull
, the sole interval iterator involved in this document iterator.
-
intervalIterators
protected final Index2IntervalIteratorMap intervalIterators
A map from indices to interval iterators.
-
currentIterators
protected final Index2IntervalIteratorMap currentIterators
A map from indices to the iterators returned for the current document. The key set may not contain an index because the related iterator has never been requested. Note that implementing subclasses might use this map just to store the result ofDocumentIterator.intervalIterators()
, leaving the tracking of current iterators to some other mechanism.
-
unmodifiableCurrentIterators
protected final Reference2ReferenceMap<Index,IntervalIterator> unmodifiableCurrentIterators
An unmodifiable wrapper aroundcurrentIterators
.
-
-
Constructor Detail
-
AbstractIntervalDocumentIterator
protected AbstractIntervalDocumentIterator(int n, ReferenceSet<Index> indices, boolean allIndexIterators, Object arg)
Creates a new instance.- Parameters:
n
- the number of underlying iterators.indices
- the set of indices appearing in the underlying iterators.allIndexIterators
- whether all underlying iterators are index iterators.arg
- an argument that will be passed togetIntervalIterator(Index, int, boolean, Object)
.
-
-
Method Detail
-
getIntervalIterator
protected abstract IntervalIterator getIntervalIterator(Index index, int n, boolean allIndexIterators, Object arg)
Creates an interval iterator suitable for thisAbstractIntervalDocumentIterator
.- Parameters:
index
- the reference index for the iterator, ornull
.n
- the number of underlying or component iterators.allIndexIterators
- whether all underlying or component iterators are index iterators.arg
- an optional argument.- Returns:
- an interval iterator suitable for this
AbstractIntervalDocumentIterator
.
-
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.
-
indices
protected static ReferenceArraySet<Index> indices(Index index, DocumentIterator... documentIterator)
A commodity static methods that computes the union of the indices of the given document iterators.- Parameters:
index
- an index that will be passed toAbstractCompositeDocumentIterator(Index, Object, DocumentIterator...)
.documentIterator
- a list of document iterators.- Returns:
- a set containing the union of the indices of the given document iterators.
-
allIndexIterators
protected static boolean allIndexIterators(DocumentIterator... documentIterator)
A commodity static methods that checks whether all specified document iterators are actually index iterators.- Parameters:
documentIterator
- a list of document iterators.- Returns:
- true if all elements of
documentIterator
are actually index iterators.
-
-