Package org.apache.uima.cas.impl
Class FsIndex_bag<T extends FeatureStructure>
- java.lang.Object
-
- java.util.AbstractCollection<T>
-
- org.apache.uima.cas.impl.FsIndex_singletype<T>
-
- org.apache.uima.cas.impl.FsIndex_bag<T>
-
- Type Parameters:
T
- the Java cover class type for this index, passed along to (wrapped) iterators producing Java cover classes NOTE: V3 doesn't support ALLOW_DUP_ADD_TO_INDEXES
- All Implemented Interfaces:
java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.Comparator<FeatureStructure>
,FSIndex<T>
,LowLevelIndex<T>
public class FsIndex_bag<T extends FeatureStructure> extends FsIndex_singletype<T>
Used for UIMA FS Bag Indexes Uses ObjHashSet to hold instances of FeatureStructures
-
-
Field Summary
Fields Modifier and Type Field Description private ObjHashSet<TOP>
index
-
Fields inherited from class org.apache.uima.cas.impl.FsIndex_singletype
casImpl, comparatorForIndexSpecs, comparatorNoTypeWithID, comparatorNoTypeWithoutID, comparatorWithID, comparatorWithoutID, isAnnotIdx, type, wr_cow
-
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 Constructor Description FsIndex_bag(CASImpl cas, Type type, int initialSize, int indexType, FSIndexComparator comparatorForIndexSpecs)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
bulkAddTo(java.util.List<T> fss)
For serialization: get all the items in this index and bulk add to an List<T>private static FSIndexComparator
cleanUpComparator(FSIndexComparator comp, CASImpl casImpl)
Substitutes an empty comparator if one is specified - may not be neededint
compare(FeatureStructure fs1, FeatureStructure fs2)
Override the super impl which uses comparators.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.protected CopyOnWriteIndexPart<T>
createCopyOnWriteIndexPart()
boolean
deleteFS(T fs)
only for backwards compatibilityT
find(FeatureStructure fs)
This is a silly method for bag indexes in V3, since dupl add to indexes is not allowed.void
flush()
int
hashCode()
void
insert(T fs)
Adding FS to an index.LowLevelIterator<T>
iterator()
Return an iterator over the index.LowLevelIterator<T>
iterator(boolean orderNotNeeded, boolean ignoreType)
Internal use, used by select framework.(package private) boolean
ll_contains(int fsAddr)
int
ll_maxAnnotSpan()
int
size()
Return the number of feature structures in this index.-
Methods inherited from class org.apache.uima.cas.impl.FsIndex_singletype
assertFsTypeMatchesIndexType, compare, compare, equals, getCasImpl, getComparator, getComparatorForIndexSpecs, getComparatorImplForIndexSpecs, getCopyOnWriteIndexPart, getIndexingStrategy, getNonNullCow, getType, getTypeCode, getTypeImpl, isSetOrSorted, isSorted, iterator, ll_compare, ll_iterator, maybeCopy, removeAll, toString, withSnapshotIterators
-
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, 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.impl.LowLevelIndex
getIntIterator, getSubIndex, getSubIndex, ll_iterator, select, select, select, select, select
-
-
-
-
Field Detail
-
index
private final ObjHashSet<TOP> index
-
-
Constructor Detail
-
FsIndex_bag
FsIndex_bag(CASImpl cas, Type type, int initialSize, int indexType, FSIndexComparator comparatorForIndexSpecs)
-
-
Method Detail
-
cleanUpComparator
private static FSIndexComparator cleanUpComparator(FSIndexComparator comp, CASImpl casImpl)
Substitutes an empty comparator if one is specified - may not be needed- See Also:
org.apache.uima.cas.impl.FSLeafIndexImpl#init(org.apache.uima.cas.admin.FSIndexComparator)
-
flush
public void flush()
- Specified by:
flush
in interfaceLowLevelIndex<T extends FeatureStructure>
- Overrides:
flush
in classFsIndex_singletype<T extends FeatureStructure>
-
insert
public final void insert(T fs)
Description copied from class:FsIndex_singletype
Adding FS to an index. not in upper interfaces because it's internal use only - called via addToIndexes etc.- Specified by:
insert
in classFsIndex_singletype<T extends FeatureStructure>
- Parameters:
fs
- the fs to be added
-
compare
public int compare(FeatureStructure fs1, FeatureStructure fs2)
Override the super impl which uses comparators. For bag indexes, compare equal only if identical addresses- Specified by:
compare
in interfacejava.util.Comparator<T extends FeatureStructure>
- Specified by:
compare
in interfaceFSIndex<T extends FeatureStructure>
- Specified by:
compare
in classFsIndex_singletype<T extends FeatureStructure>
- Parameters:
fs1
- the first Feature Structure to comparefs2
- the second Feature Structure to compare- Returns:
-1
iffs1 < fs2
;0
iffs1 = fs2
;1
else.
-
contains
public boolean contains(FeatureStructure fs)
Description copied from interface: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.
- Parameters:
fs
- A Feature Structure used a template to match for equality with the FSs in the index.- Returns:
true
if the index contains such an element.- See Also:
FSIndex.contains(FeatureStructure)
-
ll_contains
boolean ll_contains(int fsAddr)
-
find
public T find(FeatureStructure fs)
This is a silly method for bag indexes in V3, since dupl add to indexes is not allowed.- Parameters:
fs
- -- Returns:
- null or the original fs if the fs is in the index
- See Also:
FSIterator.moveTo(FeatureStructure)
-
size
public int size()
Description copied from interface:FSIndex
Return the number of feature structures in this index.- Specified by:
size
in interfacejava.util.Collection<T extends FeatureStructure>
- Specified by:
size
in interfaceFSIndex<T extends FeatureStructure>
- Specified by:
size
in classjava.util.AbstractCollection<T extends FeatureStructure>
- Returns:
- The number of FSs in this index.
- See Also:
FSIndex.size()
-
deleteFS
public boolean deleteFS(T fs)
only for backwards compatibility- Specified by:
deleteFS
in classFsIndex_singletype<T extends FeatureStructure>
- 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
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Collection<T extends FeatureStructure>
- Overrides:
hashCode
in classFsIndex_singletype<T extends FeatureStructure>
-
bulkAddTo
protected void bulkAddTo(java.util.List<T> fss)
Description copied from class:FsIndex_singletype
For serialization: get all the items in this index and bulk add to an List<T>- Specified by:
bulkAddTo
in classFsIndex_singletype<T extends FeatureStructure>
- Parameters:
fss
- the set of items to add
-
iterator
public LowLevelIterator<T> iterator(boolean orderNotNeeded, boolean ignoreType)
Description copied from interface:LowLevelIndex
Internal 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.- 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.
-
createCopyOnWriteIndexPart
protected CopyOnWriteIndexPart<T> createCopyOnWriteIndexPart()
- Specified by:
createCopyOnWriteIndexPart
in classFsIndex_singletype<T extends FeatureStructure>
-
ll_maxAnnotSpan
public int ll_maxAnnotSpan()
- Returns:
- for annotation indexes, an conservative estimate the maximum span between begin and end The value may be larger than actual.
-
iterator
public LowLevelIterator<T> iterator()
Description copied from interface:LowLevelIndex
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:
iterator
in interfacejava.util.Collection<T extends FeatureStructure>
- Specified by:
iterator
in interfaceFSIndex<T extends FeatureStructure>
- Specified by:
iterator
in interfacejava.lang.Iterable<T extends FeatureStructure>
- Specified by:
iterator
in interfaceLowLevelIndex<T extends FeatureStructure>
- Specified by:
iterator
in classjava.util.AbstractCollection<T extends FeatureStructure>
- Returns:
- An FSIterator positioned at the beginning, or an invalid iterator.
-
-