Class FsIndex_annotation<T extends AnnotationFS>
- All Implemented Interfaces:
Comparable<org.apache.uima.cas.impl.FsIndex_iicp<? extends FeatureStructure>>,Iterable<T>,Collection<T>,Comparator<FeatureStructure>,FSIndex<T>,LowLevelIndex<T>,AnnotationIndex<T>
-
Field Summary
Fields inherited from interface org.apache.uima.cas.FSIndex
BAG_INDEX, DEFAULT_BAG_INDEX, SET_INDEX, SORTED_INDEXFields inherited from interface org.apache.uima.cas.impl.LowLevelIndex
FS_ID_COMPARATOR, IS_ORDERED, IS_TYPE_ORDER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompare(FeatureStructure fs1, FeatureStructure fs2) Compare two feature structures according to the ordering relation of the index.intcompareTo(org.apache.uima.cas.impl.FsIndex_iicp<? extends FeatureStructure> cp) Maybe not used 3/2015 Compares two instances of FsIndex_iicp, for ordering.booleanCheck if the index contains an element equal to the given feature structure according to the comparators defined for this index.booleanTwo iicps are equal if and only if: - the types they index are the same, and - the comparators are equal, and - the indexing stragtegy (bag/set/sorted) are the same Used when creating the index iterator cache to select from the set of all instances of these the one that goes with the same index definition Used by CasComplete serialization to merge multiple index names referring to the same indexfind(FeatureStructure fs) Find an entry in the index "equal to" the given feature structure according to the comparators specified for this index.This is **NOT** a comparator for Feature Structures, but rather something that compares two comparator specificationsintReturn the indexing strategy.getType()Return the type of feature structures this index contains.inthashCode()booleanisEmpty()booleanisSorted()iterator()Iterator varieties All iterators are over a Type + subtypes (because that's the purpose of this class) - ambiguous / unambiguous (for AnnotationIndex) - not strict / strict (for AnnotationIndex) - ignoring type priorities or not (for any index) - "unordered" - no need to preserve order These may be combined.iterator(boolean ambiguous) Return an iterator over annotations that can be constrained to be unambiguous.iterator(boolean orderNotNeeded, boolean ignoreType) Internal use, used by select framework.iterator(boolean ambiguous, boolean strict, boolean orderNotNeeded, boolean ignoreType) intll_compare(int ref1, int ref2) Compare two Feature structures, referred to by IDsll_iterator(boolean ambiguous) Iterator over arbitrary Feature Structures, but also filters out non-AnnotationFS FeatureStructuresintintsize()Return the number of feature structures in this index.subiterator(AnnotationFS annot) Return a subiterator whose bounds are defined by the input annotation.subiterator(AnnotationFS annot, boolean ambiguous, boolean strict) Return a subiterator whose bounds are defined by theannot.toString()Create an annotation tree withannotas root node.Creates a shared copy of this FSIndex configured to produce snapshot iterators that don't throw ConcurrentModificationExceptions.Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, remove, removeAll, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, toArray, toArray, toArrayMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongMethods inherited from interface org.apache.uima.cas.FSIndex
compare, contains, find, getIndexingStrategy, getType, iterator, size, stream, subType, subTypeMethods inherited from interface org.apache.uima.cas.impl.LowLevelIndex
flush, getIntIterator, getSubIndex, getSubIndex, ll_iterator, select, select, select, select, select
-
Constructor Details
-
FsIndex_annotation
-
-
Method Details
-
iterator
Description copied from interface:AnnotationIndexReturn an iterator over annotations that can be constrained to be unambiguous.A disambiguated iterator is defined as follows. The first annotation returned is the same as would be returned by the corresponding ambiguous iterator. If the unambiguous iterator has returned
apreviously, it will next return the smallestbs.t. a < b and a.getEnd() <= b.getBegin(). In other words, thebannotation's start will be large enough to not overlap the span ofa.An unambiguous iterator makes a snapshot copy of the index containing just the disambiguated items, and iterates over that. It doesn't check for concurrent index modifications (the ambiguous iterator does check for this).
- Specified by:
iteratorin interfaceAnnotationIndex<T extends AnnotationFS>- Parameters:
ambiguous- If set to false, iterator will be unambiguous.- Returns:
- A annotation iterator.
-
iterator
public LowLevelIterator<T> iterator(boolean ambiguous, boolean strict, boolean orderNotNeeded, boolean ignoreType) - Parameters:
ambiguous- false for unambiguousstrict- true for strictorderNotNeeded- true for unorderedignoreType- -- Returns:
- -
-
subiterator
Description copied from interface:AnnotationIndexReturn a subiterator whose bounds are defined by the input annotation.The
annotis used for 3 purposes:- It is used to compute the position in the index where the iteration starts.
- It is used to compute end point where the iterator stops when moving forward.
- It is used to specify which annotations will be skipped while iterating.
The starting position is computed by first finding a position whose annotation compares equal with the
annot(this might be one of several), and then advancing until reaching a position where the annotation there is not equal to theannot. If no item in the index is equal (meaning it has the same begin, the same end, and is the same type as theannot) then the iterator is positioned to the first annotation which is greater than theannot, or if there are no annotations greater than theannot, the iterator is marked invalid.The iterator will stop (become invalid) when
- it runs out of items in the index going forward or backwards, or
- while moving forward, it reaches a point where the annotation at that position has a start
is beyond the
annot'send position, or - while moving backwards, it reaches a position in front of its original starting position.
While iterating, it operates like a
strictiterator; annotations whose end positions are > the end position ofannotare skipped.This is equivalent to returning annotations
bsuch thatannot < b, andannot.getEnd() >= b.getBegin(), skippingb'swhose end position is > annot.getEnd().
For annotations x, y,
x < yhere is to be interpreted as "x comes before y in the index", according to the rules defined in the description ofthis class.This definition implies that annotations
bthat have the same span asannotmay or may not be returned by the subiterator. This is determined by the type priorities; the subiterator will only return such an annotationbif the type ofannotprecedes the type ofbin the type priorities definition. If you have not specified the priority, or ifannotandbare of the same type, then the behavior is undefined.For example, if you have an annotation
Sof typeSentenceand an annotationPof typeParagraphthat have the same span, and you have definedParagraphbeforeSentencein your type priorities, thensubiterator(P)will give you an iterator that will returnS, butsubiterator(S)will give you an iterator that will NOT returnP. The intuition is that a Paragraph is conceptually larger than a Sentence, as defined by the type priorities.Calling
subiterator(a)is equivalent to callingsubiterator(a, true, true).. Seesubiterator(AnnotationFS, boolean, boolean).- Specified by:
subiteratorin interfaceAnnotationIndex<T extends AnnotationFS>- Parameters:
annot- Defines the boundaries of the subiterator.- Returns:
- A subiterator.
-
subiterator
Description copied from interface:AnnotationIndexReturn a subiterator whose bounds are defined by theannot.The
annotis used in 2 or 3 ways.- It specifies the left-most position in the index where the iteration starts.
- It specifies an end point where the iterator stops.
- If
strictis specified, the end point also specifies which annotations will be skipped while iterating.
The starting position is computed by first finding the position whose annotation compares equal with the
annot, and then advancing until reaching a position where the annotation there is not equal to theannot. If no item in the index is equal (meaning it has the same begin, the same end, and is the same type as theannot) then the iterator is positioned to the first annotation which is greater than theannot, or if there are no annotations greater than theannot, the iterator is marked invalid.The iterator will stop (become invalid) when
- it runs out of items in the index going forward or backwards, or
- while moving forward, it reaches a point where the annotation at that position has a start
is beyond the
annot'send position, or - while moving backwards, it reaches a position in front of its original starting position
Ignoring
strictandambiguousfor a moment, this is equivalent to returning annotationsbsuch thatannot < busing the standard annotation comparator, andannot.getEnd() >= b.getBegin(), and also bounded by the index itself.
A
strictsubiterator skips annotations whereannot.getEnd() < b.getEnd().A
ambiguous = falsespecification produces an unambigouse iterator, which computes a subset of the annotations, going forward, such that annotations whosebeginis contained within the previous returned annotation's span, are skipped.For annotations x,y,
x < yhere is to be interpreted as "x comes before y in the index", according to the rules defined in the description ofthis class.If
strict = truethen annotations whose end is >annot.getEnd()are skipped.These definitions imply that annotations
bthat have the same span asannotmay or may not be returned by the subiterator. This is determined by the type priorities; the subiterator will only return such an annotationbif the type ofannotprecedes the type ofbin the type priorities definition. If you have not specified the priority, or ifannotandbare of the same type, then the behavior is undefined.For example, if you have an annotation
Sof typeSentenceand an annotationPof typeParagraphthat have the same span, and you have definedParagraphbeforeSentencein your type priorities, thensubiterator(P)will give you an iterator that will returnS, butsubiterator(S)will give you an iterator that will NOT returnP. The intuition is that a Paragraph is conceptually larger than a Sentence, as defined by the type priorities.- Specified by:
subiteratorin interfaceAnnotationIndex<T extends AnnotationFS>- Parameters:
annot- Annotation setting boundary conditions for subiterator.ambiguous- If set tofalse, resulting iterator will be unambiguous.strict- Controls if annotations that overlap to the right are considered in or out.- Returns:
- A subiterator.
-
tree
Description copied from interface:AnnotationIndexCreate an annotation tree withannotas root node. The tree is defined as follows: for each node in the tree, the children are the sequence of annotations that would be obtained from a strict, unambiguous subiterator of the node's annotation.- Specified by:
treein interfaceAnnotationIndex<T extends AnnotationFS>- Parameters:
annot- The annotation at the root of the tree. This must be of type T or a subtype- Returns:
- The annotation tree rooted at
annot.
-
withSnapshotIterators
Description copied from interface:FSIndexCreates a shared copy of this FSIndex configured to produce snapshot iterators that don't throw ConcurrentModificationExceptions.- Specified by:
withSnapshotIteratorsin interfaceFSIndex<T extends AnnotationFS>- Returns:
- a light-weight copy of this FSIndex, configured such that any iterator created using it will be a snapshot iterator - one where a snapshot is made of the state of the index at the time the iterator is created, and where subsequent modifications to the underlying index are allowed, but don't affect the iterator (which iterates over the read-only snapshot). Iterators produced with this won't throw ConcurrentModificationExceptions.
-
toString
- Overrides:
toStringin classAbstractCollection<T extends FeatureStructure>
-
equals
Two iicps are equal if and only if: - the types they index are the same, and - the comparators are equal, and - the indexing stragtegy (bag/set/sorted) are the same Used when creating the index iterator cache to select from the set of all instances of these the one that goes with the same index definition Used by CasComplete serialization to merge multiple index names referring to the same index- Specified by:
equalsin interfaceCollection<T extends FeatureStructure>- Specified by:
equalsin interfaceComparator<T extends FeatureStructure>- Overrides:
equalsin classObject
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<T extends FeatureStructure>- Overrides:
hashCodein classObject
-
compareTo
Maybe not used 3/2015 Compares two instances of FsIndex_iicp, for ordering. Compares first using the type code of the main types If those are equal, Compares using the comparatorForIndexSpecs objects- Specified by:
compareToin interfaceComparable<T extends FeatureStructure>- See Also:
-
size
public int size()Description copied from interface:FSIndexReturn the number of feature structures in this index.- Specified by:
sizein interfaceCollection<T extends FeatureStructure>- Specified by:
sizein interfaceFSIndex<T extends FeatureStructure>- Specified by:
sizein classAbstractCollection<T extends FeatureStructure>- Returns:
- the sum of the sizes of the indexes of the type + all subtypes
-
ll_maxAnnotSpan
public int ll_maxAnnotSpan()- Specified by:
ll_maxAnnotSpanin interfaceLowLevelIndex<T extends FeatureStructure>- Returns:
- for annotation indexes, an conservative estimate the maximum span between begin and end The value may be larger than actual.
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T extends FeatureStructure>- Overrides:
isEmptyin classAbstractCollection<T extends FeatureStructure>
-
ll_compare
public int ll_compare(int ref1, int ref2) Description copied from interface:LowLevelIndexCompare two Feature structures, referred to by IDs- Specified by:
ll_comparein interfaceLowLevelIndex<T extends FeatureStructure>- Parameters:
ref1- -ref2- -- Returns:
- -
-
getIndexingStrategy
public int getIndexingStrategy()Description copied from interface:FSIndexReturn the indexing strategy.- Specified by:
getIndexingStrategyin interfaceFSIndex<T extends FeatureStructure>- Returns:
- One of
SORTED_INDEX,BAG_INDEXorSET_INDEX.
-
getComparator
- Specified by:
getComparatorin interfaceLowLevelIndex<T extends FeatureStructure>- Returns:
- a comparator used by this index to compare Feature Structures For sets, the equal is used to determine set membership For sorted, the comparator is the sort order (this comparator is without the ID)
-
getComparatorForIndexSpecs
Description copied from interface:LowLevelIndexThis is **NOT** a comparator for Feature Structures, but rather something that compares two comparator specifications- Specified by:
getComparatorForIndexSpecsin interfaceLowLevelIndex<T extends FeatureStructure>- Returns:
- -
-
getComparatorImplForIndexSpecs
-
compare
Description copied from interface:FSIndexCompare two feature structures according to the ordering relation of the index. If the input feature structures are not of the type of the index or a supertype, the result is undefined. Because the indexes compare might use only features defined in supertypes, the arguments being compared could be supertypes of the indexed type.- Specified by:
comparein interfaceComparator<T extends FeatureStructure>- Specified by:
comparein interfaceFSIndex<T extends FeatureStructure>- Parameters:
fs1- the first Feature Structure to comparefs2- the second Feature Structure to compare- Returns:
-1iffs1 < fs2;0iffs1 = fs2;1else.
-
contains
Description copied from interface:FSIndexCheck if the index contains an element equal to the given feature structure according to the comparators defined for this index. For bag indexes (which have no comparators), the equality test means the identical feature structure. Note that this is in general not the same as feature structure identity.
The element is used as a template, and may be a supertype of the type of the index, as long as the keys specified for this index can be accessed.
- Specified by:
containsin interfaceFSIndex<T extends FeatureStructure>- Parameters:
fs- A Feature Structure used a template to match for equality with the FSs in the index.- Returns:
trueif the index contains such an element.
-
find
Description copied from interface:FSIndexFind an entry in the index "equal to" the given feature structure according to the comparators specified for this index. Note that this is in general not the same as feature structure identity. For BAG indexes, it is identity, for others it means the found feature structure compares equal with the parameter in terms of the defined comparators for the index. If there are multiple different FSs in the index which compare equal with the given feature structure, an arbitrary one is returned. This differs from the moveTo(fs) operation which guarantees to move to the first feature structure occurring in the index in this case.- Specified by:
findin interfaceFSIndex<T extends FeatureStructure>- Parameters:
fs- A Feature Structure used a template to match with the Feature Structures in the index. It must have the keys needed to do the compare as specified for the index that it's in.- Returns:
- A FS equal to the template argument, or
nullif no such FS exists. - See Also:
-
getType
Description copied from interface:FSIndexReturn the type of feature structures this index contains.- Specified by:
getTypein interfaceFSIndex<T extends FeatureStructure>- Returns:
- The type of feature structures in this index.
-
getCasImpl
- Specified by:
getCasImplin interfaceLowLevelIndex<T extends FeatureStructure>- Returns:
- a CAS View associated with this iterator
-
isSorted
public boolean isSorted()- Specified by:
isSortedin interfaceLowLevelIndex<T extends FeatureStructure>- Returns:
- true if the index is sorted
-
iterator
Iterator varieties All iterators are over a Type + subtypes (because that's the purpose of this class) - ambiguous / unambiguous (for AnnotationIndex) - not strict / strict (for AnnotationIndex) - ignoring type priorities or not (for any index) - "unordered" - no need to preserve order These may be combined.- Specified by:
iteratorin interfaceCollection<T extends FeatureStructure>- Specified by:
iteratorin interfaceFSIndex<T extends FeatureStructure>- Specified by:
iteratorin interfaceIterable<T extends FeatureStructure>- Specified by:
iteratorin interfaceLowLevelIndex<T extends FeatureStructure>- Specified by:
iteratorin classAbstractCollection<T extends FeatureStructure>- Returns:
- An FSIterator positioned at the beginning, or an invalid iterator.
-
iterator
Description copied from interface:LowLevelIndexInternal use, used by select framework. Return an iterator over the index. The position of the iterator will be set to return the first item in the index. If the index is empty, the iterator position will be marked as invalid.- Specified by:
iteratorin interfaceLowLevelIndex<T extends FeatureStructure>- Parameters:
orderNotNeeded- if true, skips work while iterating to keep iterators over multiple types in sync.ignoreType- if true, the comparator used for moveTo leftmost operations will ignore typeOrder keys, if the index happens to define these- Returns:
- An FSIterator positioned at the beginning, or an invalid iterator.
-
ll_iterator
Iterator over arbitrary Feature Structures, but also filters out non-AnnotationFS FeatureStructures- Specified by:
ll_iteratorin interfaceLowLevelIndex<T extends FeatureStructure>- Parameters:
ambiguous- true for normal iteration, false to do unambiguous iteration- Returns:
- the iterator
-
getFsRepositoryImpl
-
streamNonEmptyIndexes
- Returns:
- a stream of FSIndex_singletype, for all non-empty indexes
-