Package org.apache.uima.cas.impl
Class FSIndexRepositoryImpl.PointerIterator
java.lang.Object
org.apache.uima.cas.impl.FSIndexRepositoryImpl.PointerIterator
- All Implemented Interfaces:
LowLevelIterator
,IntPointerIterator
- Direct Known Subclasses:
FSIndexRepositoryImpl.PointerIteratorUnordered
- Enclosing class:
- FSIndexRepositoryImpl
private class FSIndexRepositoryImpl.PointerIterator
extends Object
implements IntPointerIterator, LowLevelIterator
The next 3 classes (PointerIterator, PointerIteratorUnordered and LeafPointerIterator)
implement iterators for particular indexes.
PointerIteratorUnordered is used for bag and things like all indexed fs where order is not important.
It uses the same impl as PointerIterator, except it works by sequentially iterating over each of the
iterator pieces.
This class handles the concepts involved with iterating over a type and
all of its subtypes, keeping the ordering among the subtypes.
The LeafPointerIterator handles just iterating over a particular type or subtype
(the one that this class picks).
The iterator implementation for indexes. Tricky because the iterator needs to be able to move
backwards as well as forwards.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FSIndexRepositoryImpl.IndexIteratorCachePair<? extends FeatureStructure>
private final IntComparator
protected ComparableIntPointerIterator[]
(package private) int
(package private) static final int
The number of elements to keep in order before the binary heap starts.protected boolean
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
PointerIterator
(FSIndexRepositoryImpl.IndexIteratorCachePair<? extends FeatureStructure> iicp) private
PointerIterator
(FSIndexRepositoryImpl.IndexIteratorCachePair<? extends FeatureStructure> iicp, int fs) -
Method Summary
Modifier and TypeMethodDescriptionprotected ComparableIntPointerIterator<?>
checkConcurrentModification
(int i) copy()
Create a copy of this iterator.void
dec()
int
get()
protected FSIndexRepositoryImpl.IndexIteratorCachePair<? extends FeatureStructure>
getIicp()
private void
heapify_down
(ComparableIntPointerIterator it, int dir) Move the top element down in the heap until it finds its proper position.private void
heapify_up
(ComparableIntPointerIterator it, int idx, int dir) Move the idx'th element up in the heap until it finds its proper position.void
inc()
private ComparableIntPointerIterator[]
private boolean
is_before
(ComparableIntPointerIterator l, ComparableIntPointerIterator r, int dir) Test the order with which the two iterators should be used.boolean
isValid()
Check if the iterator is currently valid.int
ll_get()
Return the current FS reference.Get the index for just the top most type of this iterator (excludes subtypes).int
Return the size of the underlying index.void
moveTo
(int fs) Try to position the iterator so that the current element is greater than or equal tofsRef
, and previous elements are less thanfsRef
.(package private) void
moveTo
(int fs, boolean isExact) void
Move iterator to first FS in index.void
Move iterator to last FS in index.void
Advance the iterator.void
Move the iterator back one position.toString()
-
Field Details
-
SORTED_SECTION
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.- See Also:
-
iicp
-
iterators
-
lastValidIndex
int lastValidIndex -
wentForward
protected boolean wentForward -
iteratorComparator
-
-
Constructor Details
-
PointerIterator
private PointerIterator(FSIndexRepositoryImpl.IndexIteratorCachePair<? extends FeatureStructure> iicp) -
PointerIterator
private PointerIterator(FSIndexRepositoryImpl.IndexIteratorCachePair<? extends FeatureStructure> iicp, int fs)
-
-
Method Details
-
getIicp
-
initPointerIterator
-
isValid
public boolean isValid()Description copied from interface:LowLevelIterator
Check if the iterator is currently valid.- Specified by:
isValid
in interfaceIntPointerIterator
- Specified by:
isValid
in interfaceLowLevelIterator
- Returns:
true
iff the iterator is valid.
-
checkConcurrentModification
-
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
-r
-dir
- Direction of movement, 1 for forward, -1 for backward- Returns:
- true if the left iterator needs to be used before the right one.
-
heapify_up
Move the idx'th element up in the heap until it finds its proper position.- Parameters:
it
- indexes[idx]idx
- Element to movedir
- 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]dir
- Direction of iterator movement, 1 for forward, -1 for backward
-
moveToFirst
public void moveToFirst()Description copied from interface:LowLevelIterator
Move iterator to first FS in index. A subsequent call toisValid()
will succeed iff the index is non-empty.- Specified by:
moveToFirst
in interfaceIntPointerIterator
- Specified by:
moveToFirst
in interfaceLowLevelIterator
-
moveToLast
public void moveToLast()Description copied from interface:LowLevelIterator
Move iterator to last FS in index. A subsequent call toisValid()
will succeed iff the index is non-empty.- Specified by:
moveToLast
in interfaceIntPointerIterator
- Specified by:
moveToLast
in interfaceLowLevelIterator
-
moveToNext
public void moveToNext()Description copied from interface:LowLevelIterator
Advance the iterator. This may invalidate the iterator.- Specified by:
moveToNext
in interfaceLowLevelIterator
-
moveToPrevious
public void moveToPrevious()Description copied from interface:LowLevelIterator
Move the iterator back one position. This may invalidate the iterator.- Specified by:
moveToPrevious
in interfaceLowLevelIterator
-
get
- Specified by:
get
in interfaceIntPointerIterator
- Throws:
NoSuchElementException
-
ll_get
public int ll_get()Description copied from interface:LowLevelIterator
Return the current FS reference.- Specified by:
ll_get
in interfaceLowLevelIterator
- Returns:
- The current FS reference.
-
copy
Description copied from interface:LowLevelIterator
Create a copy of this iterator. The copy will point at the same element that this iterator is currently pointing at.- Specified by:
copy
in interfaceIntPointerIterator
- Specified by:
copy
in interfaceLowLevelIterator
- Returns:
- A copy of this iterator.
-
moveTo
public void moveTo(int fs) Description copied from interface:LowLevelIterator
Try to position the iterator so that the current element is greater than or equal tofsRef
, and previous elements are less thanfsRef
. This may invalidate the iterator. If fsRef can not be compared to FSs in the index, the results are undefined.- Specified by:
moveTo
in interfaceIntPointerIterator
- Specified by:
moveTo
in interfaceLowLevelIterator
- Parameters:
fs
- The FS reference the iterator should be set to.- See Also:
-
moveTo
void moveTo(int fs, boolean isExact) - Parameters:
fs
- the FS to move toisExact
- if true, move to this exact one (must be present), if false, move to the left-most element that is equal to fs using the comparator for the index or if none is equal, move to the next element that is greater than this fs or invalid position of all are less than this fs
-
inc
public void inc()- Specified by:
inc
in interfaceIntPointerIterator
-
dec
public void dec()- Specified by:
dec
in interfaceIntPointerIterator
-
ll_indexSize
public int ll_indexSize()Description copied from interface:LowLevelIterator
Return the size of the underlying index.- Specified by:
ll_indexSize
in interfaceLowLevelIterator
- Returns:
- The size of the index.
-
ll_getIndex
Description copied from interface:LowLevelIterator
Get the index for just the top most type of this iterator (excludes subtypes).- Specified by:
ll_getIndex
in interfaceLowLevelIterator
- Returns:
- The index.
-
toString
-