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:
java.util.Iterator<T>
,java.util.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
Fields Modifier and Type Field Description private static boolean
DEBUG
private FsIndex_iicp<T>
iicp
protected int
lastValidIteratorIndex
index into nonEmptyIterators, shows last valid oneprivate static int
SORTED_SECTION
The number of elements to keep in order before the binary heap starts.private boolean
wentForward
-
Fields inherited from class org.apache.uima.cas.impl.FsIterator_multiple_indexes
allIterators, comparatorMaybeNoTypeWithoutId, main_idx, nonEmptyIterators
-
Fields inherited from interface org.apache.uima.cas.impl.LowLevelIterator
FS_ITERATOR_LOW_LEVEL_EMPTY, IS_ORDERED
-
-
Constructor Summary
Constructors Constructor Description FsIterator_subtypes_ordered(FsIndex_iicp<T> iicp, java.util.Comparator<TOP> comparatorMaybeNoTypeWithoutId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
compare(FeatureStructure fsLeft, FeatureStructure fsRight)
Only used to compare two iterator's with different types positionFSIterator<T>
copy()
Copy this iterator.private void
dumpIteratorInfo(java.lang.String context)
java.util.Comparator<TOP>
getComparator()
T
getNvc()
Get the structure the iterator is pointing at.private void
heapify_down(LowLevelIterator<T> it, int dir)
Move the top element down in the heap until it finds its proper position.private void
heapify_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 boolean
is_before(LowLevelIterator<T> l, LowLevelIterator<T> r, int dir)
Test the order with which the two iterators should be used.boolean
isMoveToSupported()
boolean
isValid()
Check if this iterator is valid.void
moveToFirstNoReinit()
Move operators have to move a group of iterators for this type and all its subtypesvoid
moveToLastNoReinit()
Internal use same as moveToLast, but won't reset to use current contents of index if index has changedprivate void
moveToNextCmn(LowLevelIterator<T> it0)
void
moveToNextNvc()
version of moveToNext which bypasses the isValid check - call only if you've just done this check yourselfvoid
moveToNoReinit(FeatureStructure fs)
Internal use same as moveTo(fs), but won't reset to use current contents of index if index has changedvoid
moveToPreviousNvc()
version of moveToPrevious which bypasses the isValid check - call only if you've just done this check yourself-
Methods 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, size
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.uima.cas.FSIterator
add, get, getType, hasNext, hasPrevious, moveToNext, moveToPrevious, next, nextIndex, nextNvc, previous, previousIndex, previousNvc, remove, set, spliterator, stream
-
Methods inherited from interface org.apache.uima.cas.impl.LowLevelIterator
getArrayList, ll_get, ll_remove, moveTo, moveTo, moveToFirst, moveToLast
-
-
-
-
Field Detail
-
DEBUG
private static final boolean DEBUG
- See Also:
- Constant Field Values
-
SORTED_SECTION
private static final int SORTED_SECTION
The 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:
- Constant Field Values
-
lastValidIteratorIndex
protected int lastValidIteratorIndex
index into nonEmptyIterators, shows last valid one
-
wentForward
private boolean wentForward
-
iicp
private final FsIndex_iicp<T extends FeatureStructure> iicp
-
-
Constructor Detail
-
FsIterator_subtypes_ordered
public FsIterator_subtypes_ordered(FsIndex_iicp<T> iicp, java.util.Comparator<TOP> comparatorMaybeNoTypeWithoutId)
-
-
Method Detail
-
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:LowLevelIterator
Internal 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:FSIterator
version of moveToNext which bypasses the isValid check - call only if you've just done this check yourself
-
moveToNextCmn
private void moveToNextCmn(LowLevelIterator<T> it0)
- Parameters:
it0
- guaranteed to be a valid iterator by callers
-
moveToPreviousNvc
public void moveToPreviousNvc()
Description copied from interface:FSIterator
version of moveToPrevious which bypasses the isValid check - call only if you've just done this check yourself
-
is_before
private boolean is_before(LowLevelIterator<T> l, LowLevelIterator<T> r, int dir)
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
private int compare(FeatureStructure fsLeft, FeatureStructure fsRight)
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 < right, (compare maybe ignores type) 1 if left == right and left.id > right.id -1 if left == right and left.id < right.id
-
heapify_up
private void heapify_up(LowLevelIterator<T> it, int idx, int dir)
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
private void heapify_down(LowLevelIterator<T> it, int dir)
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:FSIterator
Check if this iterator is valid.- Returns:
true
if the iterator is valid.
-
getNvc
public T getNvc() throws java.util.NoSuchElementException
Description copied from interface:FSIterator
Get 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:
java.util.NoSuchElementException
-
moveToNoReinit
public void moveToNoReinit(FeatureStructure fs)
Description copied from interface:LowLevelIterator
Internal 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
public FSIterator<T> copy()
Description copied from interface:FSIterator
Copy this iterator.- Returns:
- A copy of this iterator, pointing at the same element.
-
getComparator
public java.util.Comparator<TOP> 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
private void dumpIteratorInfo(java.lang.String context)
-
-