Package org.apache.uima.cas.impl
Class FSIndexRepositoryImpl
- java.lang.Object
-
- org.apache.uima.cas.impl.FSIndexRepositoryImpl
-
- All Implemented Interfaces:
FSIndexRepositoryMgr,FSIndexRepository,LowLevelIndexRepository
public class FSIndexRepositoryImpl extends java.lang.Object implements FSIndexRepositoryMgr, LowLevelIndexRepository
There is one instance of this class per CAS View. Some parts of the data here are shared between all views of a CAS. Many things refer to specific types, and their associated Java Cover classes. Java impl classes are always used for each type; If there is no JCas cover class defined for a type, then the most specific superclass which has a JCas defined class is used; this is the class TOP or one of its subclasses. Generic typing: User facing APIs can make use of the (JCas) Java cover types, for indexes and iterators over them The general generic type used is typically written here as T extends FeatureStructure, where FeatureStructure is the super interface of all JCas types. APIs having no reference to Java cover types (i.e., low level iterators) are not generic, unless they are needed to be to pass along the associated type to other APIs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classFSIndexRepositoryImpl.IndexesForTypeInformation about all the indexes for a single type.private static classFSIndexRepositoryImpl.ProcessedIndexInfoFor processing index updates in batch mode when deserializing from a remote service; lists of FSs that were added, removed, or reindexed only used when processing updates in batch modeprivate static classFSIndexRepositoryImpl.SharedIndexInfoInformation about indexes that is shared across all views *
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringALLOW_DUP_ADD_TO_INDEXESDefine this JVM property to allow adding the same identical FS to Set and Sorted indexes more than once.private java.util.Map<TypeImpl,FsIndex_annotation<Annotation>>annotationIndexesspeedup for annotation index accessing by type, lazily initializedprivate CASImplcasReplicated per viewstatic intDEFAULT_INDEX_SIZEThe default size of an index.static java.lang.StringDISABLE_ENHANCED_WRONG_INDEXstatic booleanINCLUDE_BAG_INDEXES(package private) FSIndexRepositoryImpl.IndexesForType[]indexArrayAn array of information about defined indexes, one for each type in the type hierarchy.private java.util.BitSetindexUpdateOperationprivate java.util.List<TOP>indexUpdatesprivate static booleanIS_DISABLE_ENHANCED_WRONG_INDEX_CHECKprivate java.util.BitSetisUsedstatic booleanITEM_ADDED_TO_INDEXstatic booleanITEM_REMOVED_FROM_INDEXprivate booleanlockedprivate booleanlogProcessedprivate FSIndexRepositoryImpl.ProcessedIndexInfomPii(package private) java.util.HashMap<java.lang.String,FsIndex_iicp<TOP>>name2indexMapA map from names to FsIndex_iicps, which represent the index at the top-most type declared in the index specification.private FSIndexRepositoryImpl.SharedIndexInfosiistatic booleanSKIP_BAG_INDEXESflag used when removing FSs due to corruption avoidanceprivate IntVectorusedIndexesstatic booleanV2_ANNOTATION_COMPARE_TYPE_ORDERset next to true to debug issues with different treatment of no type priorities in v3
-
Constructor Summary
Constructors Modifier Constructor Description privateFSIndexRepositoryImpl()----------------------- Support for flattened indexes -----------------(package private)FSIndexRepositoryImpl(CASImpl cas)Constructor.(package private)FSIndexRepositoryImpl(CASImpl cas, FSIndexRepositoryImpl baseIndexRepo)Constructor for additional views.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends TOP>
voidaddback(T fs)private <T extends FeatureStructure>
voidaddDirectSubtypes(TypeImpl type, java.util.List<LowLevelIterator<T>> iteratorList)voidaddFS(int fsRef)<T extends FeatureStructure>
voidaddFS(T fs)Add a feature structure to all appropriate indexes in the repository.private <T extends TOP>
voidaddFS_common(T fs, boolean isAddback)private FsIndex_iicp<TOP>addNewIndex(FSIndexComparatorImpl comparator, int indexType)private <T extends TOP>
FsIndex_iicp<T>addNewIndex(FSIndexComparatorImpl comparator, int initialSize, int indexType)This is where the actual index gets created.(package private) <T extends TOP>
FsIndex_singletype<T>addNewIndexCore(FSIndexComparatorImpl comparatorForIndexSpecs, int initialSize, int indexingStrategy)The routine which actually creates a new index, for a single type.private FsIndex_iicp<TOP>addNewIndexRec(FSIndexComparatorImpl comp4indexSpecs, int indexType)Add an index for a type, and then (unless it's a DEFAULT_BAG_INDEX), call yourself recursively to add the indexes for all the directly subsumed subtypes.private FsIndex_iicp<TOP>addNewIndexRecursive(FSIndexComparator compForIndexSpecs, int indexType)Top level call to add the indexes for a particular index definitionprivate <T extends TOP>
voidcollectCowIndexParts(TypeImpl ti, java.util.ArrayList<CopyOnWriteIndexPart<T>> indexes)voidcommit()Commit this repository instance.private java.util.Comparator<TOP>createAnnotationFsComparator()private java.util.Comparator<TOP>createAnnotationFsComparator(FSComparators withId, FSComparators withTypeOrder)private java.util.Comparator<TOP>createAnnotationFsComparatorWithId()FSIndexComparatorcreateComparator()Create a new comparator to define a new index.booleancreateIndex(FSIndexComparator comp, java.lang.String label)Create a new sorted index.booleancreateIndex(FSIndexComparator comp, java.lang.String label, int indexType)Create a new index.(package private) <T extends FeatureStructure>
voidcreateIndex(FSIndexRepositoryImpl baseIndexRepo, java.lang.String key)create indexes in a view, by copying the baseCas's index repository's definitions Called when creating or refreshing (after deserializing) a view<T extends FeatureStructure>
booleancreateIndexNoQuestionsAsked(FSIndexComparator comp, java.lang.String label, int indexType)This is public only until the xml specifier format supports specifying index kinds (set, bag etc.).LinearTypeOrderBuildercreateTypeSortOrder()Currently not useful.voidflush()Reset all indexes, in one view.java.util.Set<TOP>getAddedFSs()<T extends FeatureStructure>
LowLevelIterator<T>getAllIndexedFS(Type type)Gets an iterator over all indexed (in this View) FeatureStructures of the specified Type (and any of its subtypes).private <T extends FeatureStructure>
voidgetAllIndexedFS(Type type, java.util.List<LowLevelIterator<T>> iteratorList)java.util.Comparator<TOP>getAnnotationFsComparator(FSComparators withId, FSComparators withTypeOrder)(package private) java.util.Comparator<TOP>getAnnotationFsComparatorWithId()java.util.Comparator<TOP>getAnnotationFsComparatorWithoutId()(package private) <T extends AnnotationFS>
FsIndex_annotation<T>getAnnotationIndex(TypeImpl ti)returns the annotation index for a type which is Annotation or a subtype of it.private static java.lang.StringgetAutoIndexNameForType(Type type)private java.util.Comparator<TOP>getCachedComparator(FSComparators withId, FSComparators withTypeOrder)CASImplgetCasImpl()private <T extends TOP>
java.util.Collection<T>getCollectionFromCows(java.util.ArrayList<CopyOnWriteIndexPart<T>> indexes)LinearTypeOrderBuildergetDefaultOrderBuilder()Get the default type order builder.LinearTypeOrdergetDefaultTypeOrder()Get the default type order.java.util.Set<TOP>getDeletedFSs()<T extends FeatureStructure>
LowLevelIndex<T>getIndex(java.lang.String label)Retrieve an index according to a label.<T extends FeatureStructure>
FSIndex<T>getIndex(java.lang.String label, Type type)Retrieve an index according to a label and a type.<T extends FeatureStructure>
FsIndex_iicp<T>getIndexBySpec(int typeCode, int indexingStrategy, FSIndexComparatorImpl comp)Get the FsIndex_iicp for a given typeCode, indexingStrategy, and comparator (type ignored)java.util.Collection<TOP>getIndexedFSs()Returns an unmodifiable collection of all of the FSs that are indexed in this view, in an arbitrary order.<T extends TOP>
java.util.Collection<T>getIndexedFSs(java.lang.Class<T> clazz)Returns an unmodifiable collection of all the FSs of this type and its subtypes, that are indexed in this view, in an arbitrary order.<T extends TOP>
java.util.Collection<T>getIndexedFSs(Type type)Returns an unmodifiable collection of all the FSs of this type and its subtypes, that are indexed in this view, in an arbitrary order.java.util.Iterator<FSIndex<TOP>>getIndexes()Get all indexes in this repository.(package private) FSIndexRepositoryImpl.IndexesForTypegetIndexesForType(int typeCode)(package private) FSIndexRepositoryImpl.IndexesForTypegetIndexesForUsedType(int i)java.util.Iterator<java.lang.String>getLabels()Get all labels for all indexes.<T extends FeatureStructure>
java.util.Iterator<java.lang.String>getLabels(FSIndexComparator comp)Get the labels for a specific comparator.FsIndex_singletype<TOP>getNonSetSingleIndexForType(int typecode)FsIndex_singletype<TOP>getNonSetSingleIndexForUsedType(int i)java.util.Set<TOP>getReindexedFSs()TypeSystemImplgetTypeSystemImpl()java.util.Set<TOP>getUpdatedFSs(java.util.Set<TOP> items)private voidinit()Initialize data.(package private) booleanisAnnotationIndex(FSIndexComparator c, int indexKind)booleanisCommitted()Check if this instance has been committed.booleanisModified()voidll_addFS(int fsRef)Add a FS reference to all appropriate indexes in the repository.voidll_addFS(int fsRef, boolean doChecks)Add a FS reference to all appropriate indexes in the repository.<T extends FeatureStructure>
LowLevelIterator<T>ll_getAllIndexedFS(Type type)<T extends FeatureStructure>
LowLevelIndex<T>ll_getIndex(java.lang.String indexName)Get an index by its name.<T extends FeatureStructure>
LowLevelIndex<T>ll_getIndex(java.lang.String indexName, int typeCode)Get an index by a name and type.java.util.Iterator<LowLevelIndex>ll_getIndexes()Get all indexes in this repository as low level indexesvoidll_removeFS(int fsRef)Remove a FS reference from all indexes in the repository.private <T extends TOP>
voidlogIndexOperation(T fs, boolean added)private voidprocessIndexUpdates()Go through the journal, and use those entries to update added, deleted, and reindexed lists in such a way as to guarantee: a FS is in only one of these lists, (or in none) For a journal "add-to-indexes" event: fs in "deleted": remove from "deleted", add to "reindexed" fs in "reindexed": do nothing fs in "added": do nothing fs not in any of these: add to "added" For a journal "remove-from-indexes" event: fs in "added": remove from "added" (don't add to "deleted") fs in "reindexed": remove from "reindexed" and add to "deleted") fs in "deleted": do nothing fs not in any of these: add to "deleted" The journal is cleared after processing.voidremoveAllExcludingSubtypes(Type type)Remove all instances of a particular type (but not its subtypes) from all indexesvoidremoveAllIncludingSubtypes(Type type)Remove all instances of a particular type (including its subtypes) from all indexesvoidremoveFS(int fsRef)voidremoveFS(FeatureStructure fs)Remove a feature structure from all indexes in the repository.(package private) booleanremoveFS_ret(TOP fs, boolean skipBagIndexes)Common remove FS code; all remove operations call this, except bulk remove (flush and removeall...) Removes FS from all indexes in this view (except bag if skipBagIndexes is true)voidremoveIndex(java.lang.String label)just for testing purposes removes the named index Also removes indexes for all subtypes.private voidremoveIndexBySpec(int typeCode, int indexingStrategy, FSIndexComparatorImpl comp)private voidsetCachedComparator(FSComparators withId, FSComparators withTypeOrder, java.util.Comparator<TOP> c)(package private) voidsetDefaultTypeOrder(LinearTypeOrder order)private java.util.stream.Stream<FsIndex_singletype<TOP>>streamNonEmptyDirectSubtypes(TypeImpl ti)java.util.stream.Stream<FsIndex_singletype<TOP>>streamNonEmptyIndexes(java.lang.Class<? extends TOP> clazz)java.util.stream.Stream<FsIndex_singletype<TOP>>streamNonEmptyIndexes(Type type)Stream instances of all of the non-empty indexes themselvesjava.lang.StringtoString()voidwalkIndexedFSs(java.util.function.Consumer<TOP> action)For this view, walk the indexed FSs in arbitrary order.voidwalkSortedIndexedFSs(java.util.function.Consumer<TOP> action)For this view, walk the indexed FSs, sorted by id (e.g.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.uima.cas.FSIndexRepository
getAllIndexedFS, removeAllExcludingSubtypes, removeAllIncludingSubtypes
-
-
-
-
Field Detail
-
ITEM_ADDED_TO_INDEX
public static final boolean ITEM_ADDED_TO_INDEX
- See Also:
- Constant Field Values
-
ITEM_REMOVED_FROM_INDEX
public static final boolean ITEM_REMOVED_FROM_INDEX
- See Also:
- Constant Field Values
-
V2_ANNOTATION_COMPARE_TYPE_ORDER
public static final boolean V2_ANNOTATION_COMPARE_TYPE_ORDER
set next to true to debug issues with different treatment of no type priorities in v3- See Also:
- Constant Field Values
-
DEFAULT_INDEX_SIZE
public static final int DEFAULT_INDEX_SIZE
The default size of an index.- See Also:
- Constant Field Values
-
SKIP_BAG_INDEXES
public static final boolean SKIP_BAG_INDEXES
flag used when removing FSs due to corruption avoidance- See Also:
- Constant Field Values
-
INCLUDE_BAG_INDEXES
public static final boolean INCLUDE_BAG_INDEXES
- See Also:
- Constant Field Values
-
ALLOW_DUP_ADD_TO_INDEXES
public static final java.lang.String ALLOW_DUP_ADD_TO_INDEXES
Define this JVM property to allow adding the same identical FS to Set and Sorted indexes more than once.- See Also:
- Constant Field Values
-
DISABLE_ENHANCED_WRONG_INDEX
public static final java.lang.String DISABLE_ENHANCED_WRONG_INDEX
- See Also:
- Constant Field Values
-
IS_DISABLE_ENHANCED_WRONG_INDEX_CHECK
private static final boolean IS_DISABLE_ENHANCED_WRONG_INDEX_CHECK
-
cas
private final CASImpl cas
Replicated per view
-
locked
private boolean locked
-
indexArray
final FSIndexRepositoryImpl.IndexesForType[] indexArray
An array of information about defined indexes, one for each type in the type hierarchy. - includes for each type, an unordered list of FsIndex_iicps for that type, corresponding to the different index definitions over that type. The key is the typecode of the type.
-
name2indexMap
final java.util.HashMap<java.lang.String,FsIndex_iicp<TOP>> name2indexMap
A map from names to FsIndex_iicps, which represent the index at the top-most type declared in the index specification. Different names may map to the same iicp. The keys are the same across all views, but the values are different, per view
-
annotationIndexes
private final java.util.Map<TypeImpl,FsIndex_annotation<Annotation>> annotationIndexes
speedup for annotation index accessing by type, lazily initialized
-
indexUpdates
private final java.util.List<TOP> indexUpdates
-
indexUpdateOperation
private final java.util.BitSet indexUpdateOperation
-
logProcessed
private boolean logProcessed
-
usedIndexes
private final IntVector usedIndexes
-
isUsed
private final java.util.BitSet isUsed
-
sii
private final FSIndexRepositoryImpl.SharedIndexInfo sii
-
mPii
private FSIndexRepositoryImpl.ProcessedIndexInfo mPii
-
-
Constructor Detail
-
FSIndexRepositoryImpl
private FSIndexRepositoryImpl()
----------------------- Support for flattened indexes -----------------
-
FSIndexRepositoryImpl
FSIndexRepositoryImpl(CASImpl cas)
Constructor. Assumption: called first before next constructor call, with the base CAS view- Parameters:
cas-
-
FSIndexRepositoryImpl
FSIndexRepositoryImpl(CASImpl cas, FSIndexRepositoryImpl baseIndexRepo)
Constructor for additional views.- Parameters:
cas-baseIndexRepository-
-
-
Method Detail
-
getIndexesForType
FSIndexRepositoryImpl.IndexesForType getIndexesForType(int typeCode)
-
getIndexesForUsedType
FSIndexRepositoryImpl.IndexesForType getIndexesForUsedType(int i)
-
init
private void init()
Initialize data. Common initialization called from the constructors.
-
createIndex
<T extends FeatureStructure> void createIndex(FSIndexRepositoryImpl baseIndexRepo, java.lang.String key)
create indexes in a view, by copying the baseCas's index repository's definitions Called when creating or refreshing (after deserializing) a view- Parameters:
baseIndexRepo- - where the base definitions arekey- - the name of the index.
-
createIndex
public boolean createIndex(FSIndexComparator comp, java.lang.String label, int indexType) throws CASAdminException
Description copied from interface:FSIndexRepositoryMgrCreate a new index. Note: if you creata a BAG_INDEX, the comparator will be ignored.- Specified by:
createIndexin interfaceFSIndexRepositoryMgr- Parameters:
comp- The comparator for the new index.label- The name of the new index.indexType- The kind of index (sorted, set, bag).- Returns:
falseiff an index with the samelabelalready exists.- Throws:
CASAdminException- If the repository is locked (after callingcommit()).- See Also:
FSIndexRepositoryMgr.createIndex(FSIndexComparator, String)
-
createIndexNoQuestionsAsked
public <T extends FeatureStructure> boolean createIndexNoQuestionsAsked(FSIndexComparator comp, java.lang.String label, int indexType)
This is public only until the xml specifier format supports specifying index kinds (set, bag etc.).- Type Parameters:
T- -- Parameters:
comp- -label- -indexType- -- Returns:
- -
-
removeIndex
public void removeIndex(java.lang.String label)
just for testing purposes removes the named index Also removes indexes for all subtypes. - NOTE this might remove another index definition's index, if it matches Only valid if no add-to-index operations have happened.- Parameters:
label- the name of the index to remove
-
flush
public void flush()
Reset all indexes, in one view.
-
addNewIndex
private FsIndex_iicp<TOP> addNewIndex(FSIndexComparatorImpl comparator, int indexType)
-
addNewIndex
private <T extends TOP> FsIndex_iicp<T> addNewIndex(FSIndexComparatorImpl comparator, int initialSize, int indexType)
This is where the actual index gets created.
-
isAnnotationIndex
boolean isAnnotationIndex(FSIndexComparator c, int indexKind)
-
addNewIndexCore
<T extends TOP> FsIndex_singletype<T> addNewIndexCore(FSIndexComparatorImpl comparatorForIndexSpecs, int initialSize, int indexingStrategy)
The routine which actually creates a new index, for a single type.- Parameters:
comparatorForIndexSpecs- -initialSize- -indexingStrategy- -- Returns:
- -
-
addNewIndexRecursive
private FsIndex_iicp<TOP> addNewIndexRecursive(FSIndexComparator compForIndexSpecs, int indexType)
Top level call to add the indexes for a particular index definition- Parameters:
compForIndexSpecs-indexType-- Returns:
- the iicp for the top new index
-
addNewIndexRec
private FsIndex_iicp<TOP> addNewIndexRec(FSIndexComparatorImpl comp4indexSpecs, int indexType)
Add an index for a type, and then (unless it's a DEFAULT_BAG_INDEX), call yourself recursively to add the indexes for all the directly subsumed subtypes.- Parameters:
comp4indexSpecs-indexType-- Returns:
- the new iicp for the new index
-
commit
public void commit()
Description copied from interface:FSIndexRepositoryMgrCommit this repository instance. No more additions will be allowed.- Specified by:
commitin interfaceFSIndexRepositoryMgr- See Also:
FSIndexRepositoryMgr.commit()
-
getDefaultTypeOrder
public LinearTypeOrder getDefaultTypeOrder()
Description copied from interface:FSIndexRepositoryMgrGet the default type order.- Specified by:
getDefaultTypeOrderin interfaceFSIndexRepositoryMgr- Returns:
- The default type order.
-
getDefaultOrderBuilder
public LinearTypeOrderBuilder getDefaultOrderBuilder()
Description copied from interface:FSIndexRepositoryMgrGet the default type order builder.- Specified by:
getDefaultOrderBuilderin interfaceFSIndexRepositoryMgr- Returns:
- The default type order builder.
-
setDefaultTypeOrder
void setDefaultTypeOrder(LinearTypeOrder order)
-
getIndexes
public java.util.Iterator<FSIndex<TOP>> getIndexes()
Description copied from interface:FSIndexRepositoryGet all indexes in this repository.- Specified by:
getIndexesin interfaceFSIndexRepository- Returns:
- All indexes.
- See Also:
FSIndexRepository.getIndexes()
-
ll_getIndexes
public java.util.Iterator<LowLevelIndex> ll_getIndexes()
Description copied from interface:FSIndexRepositoryGet all indexes in this repository as low level indexes- Specified by:
ll_getIndexesin interfaceFSIndexRepository- Returns:
- All indexes.
-
getLabels
public java.util.Iterator<java.lang.String> getLabels()
Description copied from interface:FSIndexRepositoryGet all labels for all indexes.- Specified by:
getLabelsin interfaceFSIndexRepository- Returns:
- All labels.
- See Also:
FSIndexRepository.getLabels()
-
getLabels
public <T extends FeatureStructure> java.util.Iterator<java.lang.String> getLabels(FSIndexComparator comp)
Get the labels for a specific comparator.- Type Parameters:
T- type of Feature Structure- Parameters:
comp- The comparator.- Returns:
- An iterator over the labels.
-
getIndex
public <T extends FeatureStructure> FSIndex<T> getIndex(java.lang.String label, Type type)
Description copied from interface:FSIndexRepositoryRetrieve an index according to a label and a type. The type is used to narrow down the index of a more general type to a more specific one. Generics: T is the associated Java cover class for the type.- Specified by:
getIndexin interfaceFSIndexRepository- Type Parameters:
T- The Java class associated with the type- Parameters:
label- The name of the index.type- A subtype of the type of the index.- Returns:
- The specified, or
nullif an index with that name doesn't exist. - See Also:
Find iicp by label (for type it was defined for) - if not found, return null Also return null if is an array type of some non-primitive, not TOP (???) Throw exception if type not subsumed by the top level type Search all iicps for the type to find the one with same indexing strategy and keys as the iicp for the label
-
getIndex
public <T extends FeatureStructure> LowLevelIndex<T> getIndex(java.lang.String label)
Description copied from interface:FSIndexRepositoryRetrieve an index according to a label. Generics: T is the associated Java cover class for the top type defined for this index name.- Specified by:
getIndexin interfaceFSIndexRepository- Type Parameters:
T- the Java class associated with the top-most type of the index- Parameters:
label- The name of the index.- Returns:
- The index with the name
label, ornullif no such index is defined. - See Also:
FSIndexRepository.getIndex(String)
-
removeAllExcludingSubtypes
public void removeAllExcludingSubtypes(Type type)
Remove all instances of a particular type (but not its subtypes) from all indexes- Specified by:
removeAllExcludingSubtypesin interfaceFSIndexRepository- Parameters:
type- -
-
removeAllIncludingSubtypes
public void removeAllIncludingSubtypes(Type type)
Remove all instances of a particular type (including its subtypes) from all indexes- Specified by:
removeAllIncludingSubtypesin interfaceFSIndexRepository- Parameters:
type- Type to remove (including all its subtypes) from this particular view.
-
createComparator
public FSIndexComparator createComparator()
Description copied from interface:FSIndexRepositoryMgrCreate a new comparator to define a new index.- Specified by:
createComparatorin interfaceFSIndexRepositoryMgr- Returns:
- A new comparator instance.
- See Also:
FSIndexRepositoryMgr.createComparator()
-
isCommitted
public boolean isCommitted()
Description copied from interface:FSIndexRepositoryMgrCheck if this instance has been committed.- Specified by:
isCommittedin interfaceFSIndexRepositoryMgr- Returns:
trueiff this instance has been committed.- See Also:
FSIndexRepositoryMgr.isCommitted()
-
createIndex
public boolean createIndex(FSIndexComparator comp, java.lang.String label) throws CASAdminException
Description copied from interface:FSIndexRepositoryMgrCreate a new sorted index.- Specified by:
createIndexin interfaceFSIndexRepositoryMgr- Parameters:
comp- The comparator for the new index.label- The name of the new index.- Returns:
falseiff an index with the samelabelalready exists.- Throws:
CASAdminException- If the repository is locked (after callingcommit()).- See Also:
FSIndexRepositoryMgr.createIndex(org.apache.uima.cas.admin.FSIndexComparator, java.lang.String)
-
walkIndexedFSs
public void walkIndexedFSs(java.util.function.Consumer<TOP> action)
For this view, walk the indexed FSs in arbitrary order.- Parameters:
action- the action to do on each FS
-
walkSortedIndexedFSs
public void walkSortedIndexedFSs(java.util.function.Consumer<TOP> action)
For this view, walk the indexed FSs, sorted by id (e.g. creation time)- Parameters:
action- -
-
getNonSetSingleIndexForType
public FsIndex_singletype<TOP> getNonSetSingleIndexForType(int typecode)
-
getNonSetSingleIndexForUsedType
public FsIndex_singletype<TOP> getNonSetSingleIndexForUsedType(int i)
-
addFS
public void addFS(int fsRef)
-
ll_addFS
public void ll_addFS(int fsRef)
Description copied from interface:LowLevelIndexRepositoryAdd a FS reference to all appropriate indexes in the repository.- Specified by:
ll_addFSin interfaceLowLevelIndexRepository- Parameters:
fsRef- The FS reference to be added to the repository. IffsRefis not a valid FS reference, the subsequent behavior of the system is undefined.
-
ll_removeFS
public void ll_removeFS(int fsRef)
Description copied from interface:LowLevelIndexRepositoryRemove a FS reference from all indexes in the repository. Note that this only removes the reference from the index repository, it does not free memory on the heap.- Specified by:
ll_removeFSin interfaceLowLevelIndexRepository- Parameters:
fsRef- The FS reference to be removed from the indexes.
-
addFS
public <T extends FeatureStructure> void addFS(T fs)
Description copied from interface:FSIndexRepositoryAdd a feature structure to all appropriate indexes in the repository. If no indexes exist for the type of FS that you are adding, then a bag (unsorted) index will be automatically created.Important: after you have called
addFS()on a FS, do not change the values of any features used for indexing. If you do, the index will become corrupted and may be unusable. If you need to change an index feature value, first callremoveFS()on the FS, change the feature values, then calladdFS()again.- Specified by:
addFSin interfaceFSIndexRepository- Type Parameters:
T- the generic type of the FeatureStructure- Parameters:
fs- The FS to be added.- See Also:
FSIndexRepository.addFS(org.apache.uima.cas.FeatureStructure)
-
removeFS
public void removeFS(FeatureStructure fs)
Description copied from interface:FSIndexRepositoryRemove a feature structure from all indexes in the repository.- Specified by:
removeFSin interfaceFSIndexRepository- Parameters:
fs- The FS to be removed. The fs must be the exact FS to remove, not just one which compares "equal" using the index's comparator.- See Also:
FSIndexRepository.removeFS(org.apache.uima.cas.FeatureStructure)
-
removeFS
public void removeFS(int fsRef)
-
createTypeSortOrder
public LinearTypeOrderBuilder createTypeSortOrder()
Description copied from interface:FSIndexRepositoryMgrCurrently not useful.- Specified by:
createTypeSortOrderin interfaceFSIndexRepositoryMgr- Returns:
- A new type order builder.
-
ll_getIndex
public <T extends FeatureStructure> LowLevelIndex<T> ll_getIndex(java.lang.String indexName)
Description copied from interface:LowLevelIndexRepositoryGet an index by its name.- Specified by:
ll_getIndexin interfaceLowLevelIndexRepository- Type Parameters:
T- type of Feature Structure- Parameters:
indexName- The name of the index.- Returns:
- The corresponding index, or
nullif no such index exists.
-
ll_getIndex
public <T extends FeatureStructure> LowLevelIndex<T> ll_getIndex(java.lang.String indexName, int typeCode)
Description copied from interface:LowLevelIndexRepositoryGet an index by a name and type. The type must be a subtype of the index's type. Note that there is no special checked version of this method, the type parameters are always checked.- Specified by:
ll_getIndexin interfaceLowLevelIndexRepository- Type Parameters:
T- type of Feature Structure- Parameters:
indexName- The name of the index.typeCode- The code of the desired subtype.- Returns:
- The corresponding index, or
nullif no such index exists.
-
ll_addFS
public final void ll_addFS(int fsRef, boolean doChecks)Description copied from interface:LowLevelIndexRepositoryAdd a FS reference to all appropriate indexes in the repository.- Specified by:
ll_addFSin interfaceLowLevelIndexRepository- Parameters:
fsRef- The FS reference to be added to the repository. IffsRefis not a valid FS reference, the subsequent behavior of the system is undefined.doChecks- Check if the FS reference argument is a valid reference.
-
addback
public <T extends TOP> void addback(T fs)
-
addFS_common
private <T extends TOP> void addFS_common(T fs, boolean isAddback)
-
getAutoIndexNameForType
private static final java.lang.String getAutoIndexNameForType(Type type)
-
removeFS_ret
boolean removeFS_ret(TOP fs, boolean skipBagIndexes)
Common remove FS code; all remove operations call this, except bulk remove (flush and removeall...) Removes FS from all indexes in this view (except bag if skipBagIndexes is true)- Parameters:
fs- the fs to removeskipBagIndexes- set true by protect-indexes style of temporary removal- Returns:
- true if it was removed
-
ll_getAllIndexedFS
public <T extends FeatureStructure> LowLevelIterator<T> ll_getAllIndexedFS(Type type)
-
getAllIndexedFS
public <T extends FeatureStructure> LowLevelIterator<T> getAllIndexedFS(Type type)
Description copied from interface:FSIndexRepositoryGets an iterator over all indexed (in this View) FeatureStructures of the specified Type (and any of its subtypes). The elements are returned in arbitrary order. Generics: T is the Java class for aType.- Specified by:
getAllIndexedFSin interfaceFSIndexRepository- Type Parameters:
T- The Java class associated with aType- Parameters:
type- The type- Returns:
- An iterator that returns all indexed FeatureStructures of type
aTypeand its subtypes, in no particular order.
-
getAllIndexedFS
private final <T extends FeatureStructure> void getAllIndexedFS(Type type, java.util.List<LowLevelIterator<T>> iteratorList)
-
addDirectSubtypes
private <T extends FeatureStructure> void addDirectSubtypes(TypeImpl type, java.util.List<LowLevelIterator<T>> iteratorList)
-
getIndexedFSs
public java.util.Collection<TOP> getIndexedFSs()
Description copied from interface:FSIndexRepositoryReturns an unmodifiable collection of all of the FSs that are indexed in this view, in an arbitrary order. Subsequent modifications to the indexes do not affect this collection.- Specified by:
getIndexedFSsin interfaceFSIndexRepository- Returns:
- an unmodifiable, unordered collection of all indexed (in this view) Feature Structures of the specified type (including subtypes)
-
getIndexedFSs
public <T extends TOP> java.util.Collection<T> getIndexedFSs(java.lang.Class<T> clazz)
Description copied from interface:FSIndexRepositoryReturns an unmodifiable collection of all the FSs of this type and its subtypes, that are indexed in this view, in an arbitrary order. Subsequent modifications to the indexes do not affect this collection.- Specified by:
getIndexedFSsin interfaceFSIndexRepository- Type Parameters:
T- The Java class associated with type- Parameters:
clazz- The JCas class corresponding to the type- Returns:
- an unmodifiable, unordered collection of all indexed (in this view) Feature Structures of the specified type (including subtypes)
-
getIndexedFSs
public <T extends TOP> java.util.Collection<T> getIndexedFSs(Type type)
Description copied from interface:FSIndexRepositoryReturns an unmodifiable collection of all the FSs of this type and its subtypes, that are indexed in this view, in an arbitrary order. Subsequent modifications to the indexes do not affect this collection.- Specified by:
getIndexedFSsin interfaceFSIndexRepository- Type Parameters:
T- The Java class associated with type- Parameters:
type- the type of Feature Structures to include (including subtypes)- Returns:
- an unmodifiable, unordered set of all indexed (in this view) Feature Structures of the specified type (including subtypes)
-
getCollectionFromCows
private <T extends TOP> java.util.Collection<T> getCollectionFromCows(java.util.ArrayList<CopyOnWriteIndexPart<T>> indexes)
-
collectCowIndexParts
private <T extends TOP> void collectCowIndexParts(TypeImpl ti, java.util.ArrayList<CopyOnWriteIndexPart<T>> indexes)
-
streamNonEmptyIndexes
public java.util.stream.Stream<FsIndex_singletype<TOP>> streamNonEmptyIndexes(Type type)
Stream instances of all of the non-empty indexes themselves- Parameters:
type- - the type to filter the indexes with- Returns:
- all of the non-empty indexes, one for each sorted or default bag per type
-
streamNonEmptyIndexes
public java.util.stream.Stream<FsIndex_singletype<TOP>> streamNonEmptyIndexes(java.lang.Class<? extends TOP> clazz)
-
streamNonEmptyDirectSubtypes
private java.util.stream.Stream<FsIndex_singletype<TOP>> streamNonEmptyDirectSubtypes(TypeImpl ti)
-
getAnnotationIndex
<T extends AnnotationFS> FsIndex_annotation<T> getAnnotationIndex(TypeImpl ti)
returns the annotation index for a type which is Annotation or a subtype of it. remembers answer in hashmap annotationIndexes, key = TypeImpl- Parameters:
typeCode-- Returns:
- the index for that type
-
logIndexOperation
private <T extends TOP> void logIndexOperation(T fs, boolean added)
-
processIndexUpdates
private void processIndexUpdates()
Go through the journal, and use those entries to update added, deleted, and reindexed lists in such a way as to guarantee: a FS is in only one of these lists, (or in none) For a journal "add-to-indexes" event: fs in "deleted": remove from "deleted", add to "reindexed" fs in "reindexed": do nothing fs in "added": do nothing fs not in any of these: add to "added" For a journal "remove-from-indexes" event: fs in "added": remove from "added" (don't add to "deleted") fs in "reindexed": remove from "reindexed" and add to "deleted") fs in "deleted": do nothing fs not in any of these: add to "deleted" The journal is cleared after processing.
-
getAddedFSs
public java.util.Set<TOP> getAddedFSs()
-
getDeletedFSs
public java.util.Set<TOP> getDeletedFSs()
-
getReindexedFSs
public java.util.Set<TOP> getReindexedFSs()
-
isModified
public boolean isModified()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getAnnotationFsComparator
public java.util.Comparator<TOP> getAnnotationFsComparator(FSComparators withId, FSComparators withTypeOrder)
-
createAnnotationFsComparator
private java.util.Comparator<TOP> createAnnotationFsComparator(FSComparators withId, FSComparators withTypeOrder)
-
getAnnotationFsComparatorWithoutId
public java.util.Comparator<TOP> getAnnotationFsComparatorWithoutId()
-
getAnnotationFsComparatorWithId
java.util.Comparator<TOP> getAnnotationFsComparatorWithId()
-
createAnnotationFsComparator
private java.util.Comparator<TOP> createAnnotationFsComparator()
-
createAnnotationFsComparatorWithId
private java.util.Comparator<TOP> createAnnotationFsComparatorWithId()
-
getIndexBySpec
public <T extends FeatureStructure> FsIndex_iicp<T> getIndexBySpec(int typeCode, int indexingStrategy, FSIndexComparatorImpl comp)
Get the FsIndex_iicp for a given typeCode, indexingStrategy, and comparator (type ignored)- Type Parameters:
T- type of Feature Structure- Parameters:
typeCode- -indexingStrategy- -comp- -- Returns:
- -
-
removeIndexBySpec
private void removeIndexBySpec(int typeCode, int indexingStrategy, FSIndexComparatorImpl comp)
-
getTypeSystemImpl
public TypeSystemImpl getTypeSystemImpl()
-
getCasImpl
public CASImpl getCasImpl()
-
getCachedComparator
private java.util.Comparator<TOP> getCachedComparator(FSComparators withId, FSComparators withTypeOrder)
-
setCachedComparator
private void setCachedComparator(FSComparators withId, FSComparators withTypeOrder, java.util.Comparator<TOP> c)
-
-