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:
Iterable<T>,Collection<T>,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 AbstractCollection<T>
implements 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
FieldsModifier and TypeFieldDescriptionprotected final CASImplprotected final FSIndexComparatorImplcomparator for an index, passed in as an argument to the constructorprotected final Comparator<TOP>comparator (with id) (ignoring typeorder) - used within one typeprotected final Comparator<TOP>comparator (without id) (ignoring typeorder) - used within one type - used for iterator operations where the type is requested to be ignoredprotected final Comparator<TOP>protected final Comparator<TOP>final booleanprotected final TypeImplprotected WeakReference<CopyOnWriteIndexPart<T>>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_INDEXFields inherited from interface org.apache.uima.cas.impl.LowLevelIndex
FS_ID_COMPARATOR, IS_ORDERED, IS_TYPE_ORDER -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFsIndex_singletype(CASImpl cas, Type type, int indexType, FSIndexComparator comparatorForIndexSpecs) Constructor for FsIndex_singletype. -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidassertFsTypeMatchesIndexType(FeatureStructure fs, String operation) protected abstract voidFor serialization: get all the items in this index and bulk add to an List<T>intcompare(int fs1, int fs2) abstract intcompare(FeatureStructure o1, FeatureStructure o2) This is required to avoid compilation error (but not in Eclipse) due to ambiguous interface inheritance from both FeatureStructure and Comparatorprotected abstract CopyOnWriteIndexPart<T>booleanvoidflush()This is **NOT** a comparator for Feature Structures, but rather something that compares two comparator specificationsintReturn the indexing strategy.protected CopyOnWriteIndexPart<T>getType()Return the type of feature structures this index contains.inthashCode()booleanisSorted()iterator(FeatureStructure initialPositionFs) Return an iterator over the index.intll_compare(int fs1, int fs2) Compare two Feature structures, referred to by IDsll_iterator(boolean ambiguous) Get a low-level, FS reference iterator.protected voidCalled 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 nulltoString()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, 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, 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
contains, find, size, stream, subType, subTypeMethods inherited from interface org.apache.uima.cas.impl.LowLevelIndex
getIntIterator, getSubIndex, getSubIndex, iterator, iterator, ll_iterator, ll_maxAnnotSpan, select, select, select, select, select
-
Field Details
-
casImpl
-
comparatorForIndexSpecs
comparator for an index, passed in as an argument to the constructor -
comparatorWithID
-
comparatorWithoutID
-
comparatorNoTypeWithID
comparator (with id) (ignoring typeorder) - used within one type -
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 -
type
-
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.
-
-
Constructor Details
-
FsIndex_singletype
protected FsIndex_singletype(CASImpl cas, Type type, int indexType, FSIndexComparator comparatorForIndexSpecs) Constructor for FsIndex_singletype.- Parameters:
cas- -type- -indexType- -comparatorForIndexSpecs- -
-
-
Method Details
-
toString
- Overrides:
toStringin classAbstractCollection<T extends FeatureStructure>
-
iterator
Description copied from interface:FSIndexReturn 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:
iteratorin 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
- 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
-
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.
-
ll_compare
public int ll_compare(int fs1, int fs2) Description copied from interface:LowLevelIndexCompare two Feature structures, referred to by IDs- Specified by:
ll_comparein 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
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<T extends FeatureStructure>- Overrides:
hashCodein classObject
-
equals
- Specified by:
equalsin interfaceCollection<T extends FeatureStructure>- Specified by:
equalsin interfaceComparator<T extends FeatureStructure>- Overrides:
equalsin classObject
-
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.
- See Also:
-
getTypeImpl
-
bulkAddTo
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
Description copied from interface:LowLevelIndexGet 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_iteratorin interfaceLowLevelIndex<T extends FeatureStructure>- Parameters:
ambiguous- When set tofalse, iterator will be disambiguated.- Returns:
- An iterator for this index.
-
getCasImpl
- Specified by:
getCasImplin interfaceLowLevelIndex<T extends FeatureStructure>- Returns:
- a CAS View associated with this iterator
-
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 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.
-
isSorted
public boolean isSorted()- Specified by:
isSortedin interfaceLowLevelIndex<T extends FeatureStructure>- Returns:
- true if the index is sorted
-
getNonNullCow
-
getCopyOnWriteIndexPart
- Returns:
- the copy-on-write wrapper for an index part if it exists for this index, or null
-
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:
flushin interfaceLowLevelIndex<T extends FeatureStructure>
-
compare
This is required to avoid compilation error (but not in Eclipse) due to ambiguous interface inheritance from both FeatureStructure and Comparator- Specified by:
comparein interfaceComparator<T extends FeatureStructure>- Specified by:
comparein interfaceFSIndex<T extends FeatureStructure>- Parameters:
o1- the first Feature Structure to compareo2- the second Feature Structure to compare- Returns:
-1iffs1 < fs2;0iffs1 = fs2;1else.
-
assertFsTypeMatchesIndexType
-