Package org.apache.uima.cas.impl
Class FsIndex_singletype<T extends FeatureStructure>
- java.lang.Object
-
- java.util.AbstractCollection<T>
-
- org.apache.uima.cas.impl.FsIndex_singletype<T>
-
- Type Parameters:
T
- the Java cover class type for this index, passed along to (wrapped) iterators producing Java cover classes
- All Implemented Interfaces:
java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.Comparator<FeatureStructure>
,FSIndex<T>
,LowLevelIndex<T>
- Direct Known Subclasses:
FsIndex_bag
,FsIndex_flat
,FsIndex_set_sorted
public abstract class FsIndex_singletype<T extends FeatureStructure> extends java.util.AbstractCollection<T> implements java.util.Comparator<FeatureStructure>, LowLevelIndex<T>
The common (among all index kinds - set, sorted, bag) info for an index over 1 type (excluding subtypes) SubClasses FsIndex_bag, FsIndex_flat, FsIndex_set_sorted, define the actual index repository for each kind.
-
-
Field Summary
Fields Modifier and Type Field Description protected CASImpl
casImpl
private static java.util.WeakHashMap<FSIndexComparatorImpl,java.lang.ref.WeakReference<FSIndexComparatorImpl>>
comparatorCache
shares equal FSIndexComparatorImpl comparatorForIndexSpecs objects updates and accesses are synchronizedprotected FSIndexComparatorImpl
comparatorForIndexSpecs
comparator for an index, passed in as an argument to the constructorprotected java.util.Comparator<TOP>
comparatorNoTypeWithID
comparator (with id) (ignoring typeorder) - used within one typeprotected java.util.Comparator<TOP>
comparatorNoTypeWithoutID
comparator (without id) (ignoring typeorder) - used within one type - used for iterator operations where the type is requested to be ignoredprotected java.util.Comparator<TOP>
comparatorWithID
protected java.util.Comparator<TOP>
comparatorWithoutID
private int
indexType
private static java.lang.String[]
indexTypes
boolean
isAnnotIdx
private boolean[]
isReverse
private java.lang.Object[]
keys
Info about Index Comparator (not used for bag *********** Index into these arrays is the key number (indexes can have multiple keys)private int[]
keyTypeCodes
private static java.util.concurrent.atomic.AtomicInteger
strictTypeSourceCheckMessageCount
protected TypeImpl
type
private int
typeCode
protected java.lang.ref.WeakReference<CopyOnWriteIndexPart<T>>
wr_cow
common copy on write instance or null; starts out as null Iterator creation initializes (if null).-
Fields inherited from interface org.apache.uima.cas.FSIndex
BAG_INDEX, DEFAULT_BAG_INDEX, SET_INDEX, SORTED_INDEX
-
Fields inherited from interface org.apache.uima.cas.impl.LowLevelIndex
FS_ID_COMPARATOR, IS_ORDERED, IS_TYPE_ORDER
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FsIndex_singletype(CASImpl cas, Type type, int indexType, FSIndexComparator comparatorForIndexSpecs)
Constructor for FsIndex_singletype.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
assertFsTypeMatchesIndexType(FeatureStructure fs, java.lang.String operation)
protected abstract void
bulkAddTo(java.util.List<T> v)
For serialization: get all the items in this index and bulk add to an List<T>int
compare(int fs1, int fs2)
abstract int
compare(FeatureStructure o1, FeatureStructure o2)
This is required to avoid compilation error (but not in Eclipse) due to ambiguous interface inheritance from both FeatureStructure and Comparator(package private) int
compare(FeatureStructure afs1, FeatureStructure afs2, boolean ignoreType)
protected abstract CopyOnWriteIndexPart<T>
createCopyOnWriteIndexPart()
(package private) abstract boolean
deleteFS(T fs)
boolean
equals(java.lang.Object obj)
void
flush()
CASImpl
getCasImpl()
java.util.Comparator<TOP>
getComparator()
FSIndexComparator
getComparatorForIndexSpecs()
This is **NOT** a comparator for Feature Structures, but rather something that compares two comparator specificationsFSIndexComparatorImpl
getComparatorImplForIndexSpecs()
CopyOnWriteIndexPart<T>
getCopyOnWriteIndexPart()
int
getIndexingStrategy()
Return the indexing strategy.protected CopyOnWriteIndexPart<T>
getNonNullCow()
Type
getType()
Return the type of feature structures this index contains.(package private) int
getTypeCode()
TypeImpl
getTypeImpl()
int
hashCode()
(package private) abstract void
insert(T fs)
Adding FS to an index.(package private) boolean
isSetOrSorted()
boolean
isSorted()
LowLevelIterator<T>
iterator(FeatureStructure initialPositionFs)
Return an iterator over the index.int
ll_compare(int fs1, int fs2)
Compare two Feature structures, referred to by IDsLowLevelIterator<T>
ll_iterator(boolean ambiguous)
Get a low-level, FS reference iterator.protected void
maybeCopy()
Called just before modifying an index if wr_cow has a value, tell that value to create a preserving copy of the index part, and set wr_cow to null(package private) void
removeAll()
Differs from flush in that it manipulates flags in the FSs to indicate removed.java.lang.String
toString()
FSIndex<T>
withSnapshotIterators()
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, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, toArray, toArray
-
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface org.apache.uima.cas.FSIndex
contains, find, size, stream, subType, subType
-
Methods inherited from interface org.apache.uima.cas.impl.LowLevelIndex
getIntIterator, getSubIndex, getSubIndex, iterator, iterator, ll_iterator, ll_maxAnnotSpan, select, select, select, select, select
-
-
-
-
Field Detail
-
indexTypes
private static final java.lang.String[] indexTypes
-
comparatorCache
private static final java.util.WeakHashMap<FSIndexComparatorImpl,java.lang.ref.WeakReference<FSIndexComparatorImpl>> comparatorCache
shares equal FSIndexComparatorImpl comparatorForIndexSpecs objects updates and accesses are synchronized
-
indexType
private final int indexType
-
casImpl
protected final CASImpl casImpl
-
comparatorForIndexSpecs
protected final FSIndexComparatorImpl comparatorForIndexSpecs
comparator for an index, passed in as an argument to the constructor
-
comparatorWithID
protected final java.util.Comparator<TOP> comparatorWithID
-
comparatorWithoutID
protected final java.util.Comparator<TOP> comparatorWithoutID
-
comparatorNoTypeWithID
protected final java.util.Comparator<TOP> comparatorNoTypeWithID
comparator (with id) (ignoring typeorder) - used within one type
-
comparatorNoTypeWithoutID
protected final java.util.Comparator<TOP> comparatorNoTypeWithoutID
comparator (without id) (ignoring typeorder) - used within one type - used for iterator operations where the type is requested to be ignored
-
isAnnotIdx
public final boolean isAnnotIdx
-
keys
private final java.lang.Object[] keys
Info about Index Comparator (not used for bag *********** Index into these arrays is the key number (indexes can have multiple keys)
-
keyTypeCodes
private final int[] keyTypeCodes
-
isReverse
private final boolean[] isReverse
-
type
protected final TypeImpl type
-
typeCode
private final int typeCode
-
wr_cow
protected java.lang.ref.WeakReference<CopyOnWriteIndexPart<T extends FeatureStructure>> wr_cow
common copy on write instance or null; starts out as null Iterator creation initializes (if null). A subsequent Modification to index, if this is not null: call cow.makeCopy(); set wr_cow = null do the modification index clear/flush - set to null; Weak ref so that after iterator is GC'd, and no ref's exist, this becomes null, so that future mods no longer need to do extra work.
-
strictTypeSourceCheckMessageCount
private static final java.util.concurrent.atomic.AtomicInteger strictTypeSourceCheckMessageCount
-
-
Constructor Detail
-
FsIndex_singletype
protected FsIndex_singletype(CASImpl cas, Type type, int indexType, FSIndexComparator comparatorForIndexSpecs)
Constructor for FsIndex_singletype.- Parameters:
cas
- -type
- -indexType
- -comparatorForIndexSpecs
- -
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection<T extends FeatureStructure>
-
insert
abstract void insert(T fs)
Adding FS to an index. not in upper interfaces because it's internal use only - called via addToIndexes etc.- Parameters:
fs
- the fs to be added
-
deleteFS
abstract boolean deleteFS(T fs)
- Parameters:
fs
- - the Feature Structure to be removed. Only this exact Feature Structure is removed (this is a stronger test than, for example, what moveTo(fs) does, where the fs in that case is used as a template). It is not an error if this exact Feature Structure is not in an index.- Returns:
- true if something was removed, false if not found
-
iterator
public LowLevelIterator<T> iterator(FeatureStructure initialPositionFs)
Description copied from interface:FSIndex
Return an iterator over the index. The position of the iterator will be set such that the feature structure returned by a call to the iterator'sget()
method is greater than or equal tofs
, and any previous FS is less thanFS
(the iterator is positioned at the earliest of equal values). If no such position exists, the iterator will be invalid.- Specified by:
iterator
in interfaceFSIndex<T extends FeatureStructure>
- Parameters:
initialPositionFs
- A feature structure template (may be a supertype of T) having keys used in the index compare function, specifying where to initially position the iterator.- Returns:
- An iterator positioned at
fs
, if it exists; else, an invalid iterator.
-
getComparator
public java.util.Comparator<TOP> getComparator()
- Specified by:
getComparator
in 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
public FSIndexComparator getComparatorForIndexSpecs()
Description copied from interface:LowLevelIndex
This is **NOT** a comparator for Feature Structures, but rather something that compares two comparator specifications- Specified by:
getComparatorForIndexSpecs
in interfaceLowLevelIndex<T extends FeatureStructure>
- Returns:
- -
-
getComparatorImplForIndexSpecs
public FSIndexComparatorImpl getComparatorImplForIndexSpecs()
-
getIndexingStrategy
public int getIndexingStrategy()
Description copied from interface:FSIndex
Return the indexing strategy.- Specified by:
getIndexingStrategy
in interfaceFSIndex<T extends FeatureStructure>
- Returns:
- One of
SORTED_INDEX
,BAG_INDEX
orSET_INDEX
.
-
ll_compare
public int ll_compare(int fs1, int fs2)
Description copied from interface:LowLevelIndex
Compare two Feature structures, referred to by IDs- Specified by:
ll_compare
in interfaceLowLevelIndex<T extends FeatureStructure>
- Parameters:
fs1
- -fs2
- -- Returns:
- 0 if equal, < 0 if fs1 < fs2, > 0 if fs1 > fs2
-
compare
public int compare(int fs1, int fs2)
- Parameters:
fs1
- -fs2
- -- Returns:
- 0 if equal, < 0 if fs1 < fs2, > 0 if fs1 > fs2
-
compare
int compare(FeatureStructure afs1, FeatureStructure afs2, boolean ignoreType)
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Collection<T extends FeatureStructure>
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfacejava.util.Collection<T extends FeatureStructure>
- Specified by:
equals
in interfacejava.util.Comparator<T extends FeatureStructure>
- Overrides:
equals
in classjava.lang.Object
-
getType
public Type getType()
Description copied from interface:FSIndex
Return the type of feature structures this index contains.- Specified by:
getType
in interfaceFSIndex<T extends FeatureStructure>
- Returns:
- The type of feature structures in this index.
- See Also:
FSIndex.getType()
-
getTypeImpl
public TypeImpl getTypeImpl()
-
getTypeCode
int getTypeCode()
-
bulkAddTo
protected abstract void bulkAddTo(java.util.List<T> v)
For serialization: get all the items in this index and bulk add to an List<T>- Parameters:
v
- the set of items to add
-
ll_iterator
public LowLevelIterator<T> ll_iterator(boolean ambiguous)
Description copied from interface:LowLevelIndex
Get a low-level, FS reference iterator. This iterator can be disambiguated. This means that only non-overlapping annotations will be returned. Non-annotation FSs will be filtered in this mode.- Specified by:
ll_iterator
in interfaceLowLevelIndex<T extends FeatureStructure>
- Parameters:
ambiguous
- When set tofalse
, iterator will be disambiguated.- Returns:
- An iterator for this index.
-
getCasImpl
public CASImpl getCasImpl()
- Specified by:
getCasImpl
in interfaceLowLevelIndex<T extends FeatureStructure>
- Returns:
- a CAS View associated with this iterator
-
withSnapshotIterators
public FSIndex<T> withSnapshotIterators()
Description copied from interface:FSIndex
Creates a shared copy of this FSIndex configured to produce snapshot iterators that don't throw ConcurrentModificationExceptions.- Specified by:
withSnapshotIterators
in interfaceFSIndex<T extends FeatureStructure>
- 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.
-
isSetOrSorted
boolean isSetOrSorted()
-
isSorted
public boolean isSorted()
- Specified by:
isSorted
in interfaceLowLevelIndex<T extends FeatureStructure>
- Returns:
- true if the index is sorted
-
removeAll
void removeAll()
Differs from flush in that it manipulates flags in the FSs to indicate removed. This can only be done if we can guarantee the FS is not indexed **in any view**. We do that by only resetting if it is a subtype of annotation base, which is guaranteed to be indexed only in 1 view.
-
getNonNullCow
protected CopyOnWriteIndexPart<T> getNonNullCow()
-
getCopyOnWriteIndexPart
public CopyOnWriteIndexPart<T> getCopyOnWriteIndexPart()
- Returns:
- the copy-on-write wrapper for an index part if it exists for this index, or null
-
createCopyOnWriteIndexPart
protected abstract CopyOnWriteIndexPart<T> createCopyOnWriteIndexPart()
-
maybeCopy
protected void maybeCopy()
Called just before modifying an index if wr_cow has a value, tell that value to create a preserving copy of the index part, and set wr_cow to null
-
flush
public void flush()
- Specified by:
flush
in interfaceLowLevelIndex<T extends FeatureStructure>
-
compare
public abstract int compare(FeatureStructure o1, FeatureStructure o2)
This is required to avoid compilation error (but not in Eclipse) due to ambiguous interface inheritance from both FeatureStructure and Comparator- Specified by:
compare
in interfacejava.util.Comparator<T extends FeatureStructure>
- Specified by:
compare
in interfaceFSIndex<T extends FeatureStructure>
- Parameters:
o1
- the first Feature Structure to compareo2
- the second Feature Structure to compare- Returns:
-1
iffs1 < fs2
;0
iffs1 = fs2
;1
else.
-
assertFsTypeMatchesIndexType
protected final void assertFsTypeMatchesIndexType(FeatureStructure fs, java.lang.String operation)
-
-