Package org.apache.uima.cas.impl
Class FsIterator_subtypes_ordered<T extends FeatureStructure>
java.lang.Object
org.apache.uima.cas.impl.FsIterator_multiple_indexes<T>
org.apache.uima.cas.impl.FsIterator_subtypes_ordered<T>
- Type Parameters:
T- result type
- All Implemented Interfaces:
Iterator<T>,ListIterator<T>,FSIterator<T>,LowLevelIterator<T>
public class FsIterator_subtypes_ordered<T extends FeatureStructure>
extends FsIterator_multiple_indexes<T>
Performs an ordered iteration among a set of iterators, each one corresponding to the type or
subtype of the uppermost type.
The set of iterators is maintained in an array, with the 0th element being the current valid
iterator.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final booleanprivate final FsIndex_iicp<T> protected intindex into nonEmptyIterators, shows last valid oneprivate static final intThe number of elements to keep in order before the binary heap starts.private booleanFields inherited from class org.apache.uima.cas.impl.FsIterator_multiple_indexes
allIterators, comparatorMaybeNoTypeWithoutId, main_idx, nonEmptyIteratorsFields inherited from interface org.apache.uima.cas.impl.LowLevelIterator
FS_ITERATOR_LOW_LEVEL_EMPTY, IS_ORDERED -
Constructor Summary
ConstructorsConstructorDescriptionFsIterator_subtypes_ordered(FsIndex_iicp<T> iicp, Comparator<TOP> comparatorMaybeNoTypeWithoutId) -
Method Summary
Modifier and TypeMethodDescriptionprivate intcompare(FeatureStructure fsLeft, FeatureStructure fsRight) Only used to compare two iterator's with different types positioncopy()Copy this iterator.private voiddumpIteratorInfo(String context) getNvc()Get the structure the iterator is pointing at.private voidheapify_down(LowLevelIterator<T> it, int dir) Move the top element down in the heap until it finds its proper position.private voidheapify_up(LowLevelIterator<T> it, int idx, int dir) Move the idx'th iterator element up in the heap until it finds its proper position.private booleanis_before(LowLevelIterator<T> l, LowLevelIterator<T> r, int dir) Test the order with which the two iterators should be used.booleanbooleanisValid()Check if this iterator is valid.voidMove operators have to move a group of iterators for this type and all its subtypesvoidInternal use same as moveToLast, but won't reset to use current contents of index if index has changedprivate voidmoveToNextCmn(LowLevelIterator<T> it0) voidversion of moveToNext which bypasses the isValid check - call only if you've just done this check yourselfvoidInternal use same as moveTo(fs), but won't reset to use current contents of index if index has changedvoidversion of moveToPrevious which bypasses the isValid check - call only if you've just done this check yourselfMethods inherited from class org.apache.uima.cas.impl.FsIterator_multiple_indexes
isIndexesHaveBeenUpdated, ll_getIndex, ll_indexSizeMaybeNotCurrent, ll_maxAnnotSpan, maybeReinitIterator, separate_into_empty_indexes_and_non_empty_iterators, sizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.uima.cas.FSIterator
add, get, getType, hasNext, hasPrevious, moveToNext, moveToPrevious, next, nextIndex, nextNvc, previous, previousIndex, previousNvc, remove, set, spliterator, streamMethods inherited from interface java.util.Iterator
forEachRemainingMethods inherited from interface org.apache.uima.cas.impl.LowLevelIterator
getArrayList, ll_get, ll_remove, moveTo, moveTo, moveToFirst, moveToLast
-
Field Details
-
DEBUG
private static final boolean DEBUG- See Also:
-
SORTED_SECTION
private static final int SORTED_SECTIONThe number of elements to keep in order before the binary heap starts. This section helps the performance in cases where a couple of types dominate the index. The sorted section is searched sequentially. Above the sorted section, the search is done using binary search- See Also:
-
lastValidIteratorIndex
protected int lastValidIteratorIndexindex into nonEmptyIterators, shows last valid one -
wentForward
private boolean wentForward -
iicp
-
-
Constructor Details
-
FsIterator_subtypes_ordered
public FsIterator_subtypes_ordered(FsIndex_iicp<T> iicp, Comparator<TOP> comparatorMaybeNoTypeWithoutId)
-
-
Method Details
-
moveToFirstNoReinit
public void moveToFirstNoReinit()Move operators have to move a group of iterators for this type and all its subtypes -
moveToLastNoReinit
public void moveToLastNoReinit()Description copied from interface:LowLevelIteratorInternal use same as moveToLast, but won't reset to use current contents of index if index has changed -
moveToNextNvc
public void moveToNextNvc()Description copied from interface:FSIteratorversion of moveToNext which bypasses the isValid check - call only if you've just done this check yourself -
moveToNextCmn
- Parameters:
it0- guaranteed to be a valid iterator by callers
-
moveToPreviousNvc
public void moveToPreviousNvc()Description copied from interface:FSIteratorversion of moveToPrevious which bypasses the isValid check - call only if you've just done this check yourself -
is_before
Test the order with which the two iterators should be used. Introduces arbitrary ordering for equivalent FSs. Only called with valid iterators.- Parameters:
l- - guaranteed to ba a valid iterator by callersr- - guaranteed to be a valid iterator by callersdir- Direction of movement, 1 for forward, -1 for backward- Returns:
- true if the left iterator needs to be used before the right one.
-
compare
Only used to compare two iterator's with different types position- Parameters:
fsLeft- the left iterator's elementfsRight- the right iterator's element- Returns:
- 1 if left > right, (compare maybe ignores type) -1 if left invalid input: '<' right, (compare maybe ignores type) 1 if left == right and left.id > right.id -1 if left == right and left.id invalid input: '<' right.id
-
heapify_up
Move the idx'th iterator element up in the heap until it finds its proper position. Up means previous iterators are before it- Parameters:
it- indexes[idx], guaranteed to be "valid"idx- Element to move, nonEmptyIterators[i] == itdir- Direction of iterator movement, 1 for forward, -1 for backward
-
heapify_down
Move the top element down in the heap until it finds its proper position.- Parameters:
it- indexes[0], may be invaliddir- Direction of iterator movement, 1 for forward, -1 for backward
-
isValid
public boolean isValid()Description copied from interface:FSIteratorCheck if this iterator is valid.- Returns:
trueif the iterator is valid.
-
getNvc
Description copied from interface:FSIteratorGet the structure the iterator is pointing at. Throws various unchecked exceptions, if the iterator is not valid- Returns:
- The structure the iterator is pointing at.
- Throws:
NoSuchElementException
-
moveToNoReinit
Description copied from interface:LowLevelIteratorInternal use same as moveTo(fs), but won't reset to use current contents of index if index has changed- Parameters:
fs- the fs to use as the template identifying the place to move to
-
copy
Description copied from interface:FSIteratorCopy this iterator.- Returns:
- A copy of this iterator, pointing at the same element.
-
getComparator
- Returns:
- the comparator used by this iterator. It is always a withoutID style, and may be either a withType or NoType style.
-
isMoveToSupported
public boolean isMoveToSupported()- Returns:
- false if this iterator is over an unordered collection or set or bag
-
dumpIteratorInfo
-