public class FsIndex_annotation<T extends AnnotationFS> extends AbstractCollection<T> implements AnnotationIndex<T>
BAG_INDEX, DEFAULT_BAG_INDEX, SET_INDEX, SORTED_INDEX
FS_ID_COMPARATOR, IS_ORDERED, IS_TYPE_ORDER
Constructor and Description |
---|
FsIndex_annotation(FsIndex_singletype<T> fsIndex_singletype) |
Modifier and Type | Method and Description |
---|---|
int |
compare(FeatureStructure fs1,
FeatureStructure fs2)
Compare two feature structures according to the ordering relation of the index.
|
int |
compareTo(org.apache.uima.cas.impl.FsIndex_iicp<? extends FeatureStructure> cp)
Maybe not used 3/2015
Compares two instances of FsIndex_iicp, for ordering.
|
boolean |
contains(FeatureStructure fs)
Check if the index contains an element equal to the given feature structure according to the
comparators defined for this index.
|
boolean |
equals(Object o)
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
|
T |
find(FeatureStructure fs)
Find an entry in the index "equal to" the given feature structure according to the comparators
specified for this index.
|
CASImpl |
getCasImpl() |
Comparator<TOP> |
getComparator() |
FSIndexComparator |
getComparatorForIndexSpecs()
This is **NOT** a comparator for Feature Structures, but rather something that compares two
comparator specifications
|
FSIndexComparatorImpl |
getComparatorImplForIndexSpecs() |
FSIndexRepositoryImpl |
getFsRepositoryImpl() |
int |
getIndexingStrategy()
Return the indexing strategy.
|
Type |
getType()
Return the type of feature structures this index contains.
|
int |
hashCode() |
boolean |
isEmpty() |
boolean |
isSorted() |
LowLevelIterator<T> |
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.
|
LowLevelIterator<T> |
iterator(boolean ambiguous)
Return an iterator over annotations that can be constrained to be unambiguous.
|
LowLevelIterator<T> |
iterator(boolean orderNotNeeded,
boolean ignoreType)
Internal use, used by select framework.
|
LowLevelIterator<T> |
iterator(boolean ambiguous,
boolean strict,
boolean orderNotNeeded,
boolean ignoreType) |
int |
ll_compare(int ref1,
int ref2)
Compare two Feature structures, referred to by IDs
|
LowLevelIterator<T> |
ll_iterator(boolean ambiguous)
Iterator over arbitrary Feature Structures, but also filters out non-AnnotationFS
FeatureStructures
|
int |
ll_maxAnnotSpan() |
int |
size()
Return the number of feature structures in this index.
|
Stream<FsIndex_singletype<TOP>> |
streamNonEmptyIndexes() |
FSIterator<T> |
subiterator(AnnotationFS annot)
Return a subiterator whose bounds are defined by the input annotation.
|
FSIterator<T> |
subiterator(AnnotationFS annot,
boolean ambiguous,
boolean strict)
Return a subiterator whose bounds are defined by the
annot . |
String |
toString() |
AnnotationTree<T> |
tree(T annot)
Create an annotation tree with
annot as root node. |
FSIndex<T> |
withSnapshotIterators()
Creates a shared copy of this FSIndex configured to produce snapshot iterators that don't throw
ConcurrentModificationExceptions.
|
add, addAll, clear, contains, containsAll, remove, removeAll, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compare, contains, find, getIndexingStrategy, getType, iterator, iterator, select, select, select, select, select, size, stream, subType, subType
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, toArray, toArray
comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
flush, getIntIterator, getSubIndex, getSubIndex, ll_iterator, select, select, select, select, select
public FsIndex_annotation(FsIndex_singletype<T> fsIndex_singletype)
public LowLevelIterator<T> iterator(boolean ambiguous)
AnnotationIndex
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 a
previously, it will next return the smallest b
s.t. a <
b and a.getEnd() <= b.getBegin(). In other words, the b
annotation's start will
be large enough to not overlap the span of a
.
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).
iterator
in interface AnnotationIndex<T extends AnnotationFS>
ambiguous
- If set to false, iterator will be unambiguous.public LowLevelIterator<T> iterator(boolean ambiguous, boolean strict, boolean orderNotNeeded, boolean ignoreType)
ambiguous
- false for unambiguousstrict
- true for strictorderNotNeeded
- true for unorderedignoreType
- -public FSIterator<T> subiterator(AnnotationFS annot)
AnnotationIndex
The annot
is used for 3 purposes:
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 the annot
. If no item in the
index is equal (meaning it has the same begin, the same end, and is the same type as the
annot
) then the iterator is positioned to the first annotation which is greater
than the annot
, or if there are no annotations greater than the
annot
, the iterator is marked invalid.
The iterator will stop (become invalid) when
annot's
end position, or
While iterating, it operates like a strict
iterator; annotations whose end
positions are > the end position of annot
are skipped.
This is equivalent to returning annotations b
such that
annot < b
, andannot.getEnd() >= b.getBegin()
, skipping b's
whose end
position is > annot.getEnd().
For annotations x, y, x < y
here is to be interpreted as "x comes before y in
the index", according to the rules defined in the description of this
class
.
This definition implies that annotations b
that have the same span as
annot
may or may not be returned by the subiterator. This is determined by the
type priorities; the subiterator will only return such an annotation b
if the type
of annot
precedes the type of b
in the type priorities definition. If
you have not specified the priority, or if annot
and b
are of the
same type, then the behavior is undefined.
For example, if you have an annotation S
of type Sentence
and an
annotation P
of type Paragraph
that have the same span, and you have
defined Paragraph
before Sentence
in your type priorities, then
subiterator(P)
will give you an iterator that will return S
, but
subiterator(S)
will give you an iterator that will NOT return P
. The
intuition is that a Paragraph is conceptually larger than a Sentence, as defined by the type
priorities.
Calling subiterator(a)
is equivalent to calling
subiterator(a, true, true).
. See
subiterator(AnnotationFS, boolean,
boolean)
.
subiterator
in interface AnnotationIndex<T extends AnnotationFS>
annot
- Defines the boundaries of the subiterator.public FSIterator<T> subiterator(AnnotationFS annot, boolean ambiguous, boolean strict)
AnnotationIndex
annot
.
The annot
is used in 2 or 3 ways.
strict
is 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 the annot
. If no item in the index is equal (meaning it has
the same begin, the same end, and is the same type as the annot
) then the iterator
is positioned to the first annotation which is greater than the annot
, or if there
are no annotations greater than the annot
, the iterator is marked invalid.
The iterator will stop (become invalid) when
annot's
end position, or
Ignoring strict
and ambiguous
for a moment, this is equivalent to
returning annotations b
such that
annot < b
using the standard annotation comparator, andannot.getEnd() >= b.getBegin()
, and also bounded by the index itself.
A strict
subiterator skips annotations where
annot.getEnd() < b.getEnd()
.
A ambiguous = false
specification produces an unambigouse iterator, which computes
a subset of the annotations, going forward, such that annotations whose begin
is
contained within the previous returned annotation's span, are skipped.
For annotations x,y, x < y
here is to be interpreted as "x comes before y in
the index", according to the rules defined in the description of this
class
.
If strict = true
then annotations whose end is > annot.getEnd()
are skipped.
These definitions imply that annotations b
that have the same span as
annot
may or may not be returned by the subiterator. This is determined by the
type priorities; the subiterator will only return such an annotation b
if the type
of annot
precedes the type of b
in the type priorities definition. If
you have not specified the priority, or if annot
and b
are of the
same type, then the behavior is undefined.
For example, if you have an annotation S
of type Sentence
and an
annotation P
of type Paragraph
that have the same span, and you have
defined Paragraph
before Sentence
in your type priorities, then
subiterator(P)
will give you an iterator that will return S
, but
subiterator(S)
will give you an iterator that will NOT return P
. The
intuition is that a Paragraph is conceptually larger than a Sentence, as defined by the type
priorities.
subiterator
in interface AnnotationIndex<T extends AnnotationFS>
annot
- Annotation setting boundary conditions for subiterator.ambiguous
- If set to false
, resulting iterator will be unambiguous.strict
- Controls if annotations that overlap to the right are considered in or out.public AnnotationTree<T> tree(T annot)
AnnotationIndex
annot
as 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.tree
in interface AnnotationIndex<T extends AnnotationFS>
annot
- The annotation at the root of the tree. This must be of type T or a subtypeannot
.public FSIndex<T> withSnapshotIterators()
FSIndex
withSnapshotIterators
in interface FSIndex<T extends AnnotationFS>
public String toString()
toString
in class AbstractCollection<T extends FeatureStructure>
public boolean equals(Object o)
equals
in interface Collection<T extends FeatureStructure>
equals
in interface Comparator<FeatureStructure>
equals
in class Object
public int hashCode()
hashCode
in interface Collection<T extends FeatureStructure>
hashCode
in class Object
public int compareTo(org.apache.uima.cas.impl.FsIndex_iicp<? extends FeatureStructure> cp)
compareTo
in interface Comparable<org.apache.uima.cas.impl.FsIndex_iicp<? extends FeatureStructure>>
Comparable.compareTo(Object)
public int size()
FSIndex
size
in interface Collection<T extends FeatureStructure>
size
in interface FSIndex<T extends FeatureStructure>
size
in class AbstractCollection<T extends FeatureStructure>
public int ll_maxAnnotSpan()
ll_maxAnnotSpan
in interface LowLevelIndex<T extends FeatureStructure>
public boolean isEmpty()
isEmpty
in interface Collection<T extends FeatureStructure>
isEmpty
in class AbstractCollection<T extends FeatureStructure>
public int ll_compare(int ref1, int ref2)
LowLevelIndex
ll_compare
in interface LowLevelIndex<T extends FeatureStructure>
ref1
- -ref2
- -public int getIndexingStrategy()
FSIndex
getIndexingStrategy
in interface FSIndex<T extends FeatureStructure>
SORTED_INDEX
, BAG_INDEX
or SET_INDEX
.public Comparator<TOP> getComparator()
getComparator
in interface LowLevelIndex<T extends FeatureStructure>
public FSIndexComparator getComparatorForIndexSpecs()
LowLevelIndex
getComparatorForIndexSpecs
in interface LowLevelIndex<T extends FeatureStructure>
public FSIndexComparatorImpl getComparatorImplForIndexSpecs()
public int compare(FeatureStructure fs1, FeatureStructure fs2)
FSIndex
compare
in interface Comparator<FeatureStructure>
compare
in interface FSIndex<T extends FeatureStructure>
fs1
- the first Feature Structure to comparefs2
- the second Feature Structure to compare-1
if fs1 < fs2
; 0
if fs1 = fs2
;
1
else.public boolean contains(FeatureStructure fs)
FSIndex
Check 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.
contains
in interface FSIndex<T extends FeatureStructure>
fs
- A Feature Structure used a template to match for equality with the FSs in the index.true
if the index contains such an element.public T find(FeatureStructure fs)
FSIndex
find
in interface FSIndex<T extends FeatureStructure>
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.null
if no such FS exists.FSIterator.moveTo(FeatureStructure)
public Type getType()
FSIndex
getType
in interface FSIndex<T extends FeatureStructure>
public CASImpl getCasImpl()
getCasImpl
in interface LowLevelIndex<T extends FeatureStructure>
public boolean isSorted()
isSorted
in interface LowLevelIndex<T extends FeatureStructure>
public LowLevelIterator<T> iterator()
iterator
in interface Iterable<T extends FeatureStructure>
iterator
in interface Collection<T extends FeatureStructure>
iterator
in interface FSIndex<T extends FeatureStructure>
iterator
in interface LowLevelIndex<T extends FeatureStructure>
iterator
in class AbstractCollection<T extends FeatureStructure>
public LowLevelIterator<T> iterator(boolean orderNotNeeded, boolean ignoreType)
LowLevelIndex
iterator
in interface LowLevelIndex<T extends FeatureStructure>
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 thesepublic LowLevelIterator<T> ll_iterator(boolean ambiguous)
ll_iterator
in interface LowLevelIndex<T extends FeatureStructure>
ambiguous
- true for normal iteration, false to do unambiguous iterationpublic FSIndexRepositoryImpl getFsRepositoryImpl()
public Stream<FsIndex_singletype<TOP>> streamNonEmptyIndexes()
Copyright © 2006–2022 The Apache Software Foundation. All rights reserved.