public class FSIndexRepositoryImpl extends Object implements FSIndexRepositoryMgr, LowLevelIndexRepository
Modifier and Type | Field and Description |
---|---|
static 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.
|
static int |
DEFAULT_INDEX_SIZE
The default size of an index.
|
static String |
DISABLE_ENHANCED_WRONG_INDEX |
static boolean |
INCLUDE_BAG_INDEXES |
static boolean |
ITEM_ADDED_TO_INDEX |
static boolean |
ITEM_REMOVED_FROM_INDEX |
static boolean |
SKIP_BAG_INDEXES
flag used when removing FSs due to corruption avoidance
|
static boolean |
V2_ANNOTATION_COMPARE_TYPE_ORDER
set next to true to debug issues with different treatment of no type priorities in v3
|
Modifier and Type | Method and Description |
---|---|
<T extends TOP> |
addback(T fs) |
void |
addFS(int fsRef) |
<T extends FeatureStructure> |
addFS(T fs)
Add a feature structure to all appropriate indexes in the repository.
|
void |
commit()
Commit this repository instance.
|
FSIndexComparator |
createComparator()
Create a new comparator to define a new index.
|
boolean |
createIndex(FSIndexComparator comp,
String label)
Create a new sorted index.
|
boolean |
createIndex(FSIndexComparator comp,
String label,
int indexType)
Create a new index.
|
<T extends FeatureStructure> |
createIndexNoQuestionsAsked(FSIndexComparator comp,
String label,
int indexType)
This is public only until the xml specifier format supports specifying index kinds (set, bag
etc.).
|
LinearTypeOrderBuilder |
createTypeSortOrder()
Currently not useful.
|
void |
flush()
Reset all indexes, in one view.
|
Set<TOP> |
getAddedFSs() |
<T extends FeatureStructure> |
getAllIndexedFS(Type type)
Gets an iterator over all indexed (in this View) FeatureStructures of the specified Type (and any of its
subtypes).
|
Comparator<TOP> |
getAnnotationFsComparator(FSComparators withId,
FSComparators withTypeOrder) |
Comparator<TOP> |
getAnnotationFsComparatorWithoutId() |
CASImpl |
getCasImpl() |
LinearTypeOrderBuilder |
getDefaultOrderBuilder()
Get the default type order builder.
|
LinearTypeOrder |
getDefaultTypeOrder()
Get the default type order.
|
Set<TOP> |
getDeletedFSs() |
<T extends FeatureStructure> |
getIndex(String label)
Retrieve an index according to a label.
|
<T extends FeatureStructure> |
getIndex(String label,
Type type)
Retrieve an index according to a label and a type.
|
<T extends FeatureStructure> |
getIndexBySpec(int typeCode,
int indexingStrategy,
FSIndexComparatorImpl comp)
Get the FsIndex_iicp for a given typeCode, indexingStrategy, and comparator (type ignored)
|
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> |
getIndexedFSs(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> |
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.
|
Iterator<FSIndex<TOP>> |
getIndexes()
Get all indexes in this repository.
|
Iterator<String> |
getLabels()
Get all labels for all indexes.
|
<T extends FeatureStructure> |
getLabels(FSIndexComparator comp)
Get the labels for a specific comparator.
|
FsIndex_singletype<TOP> |
getNonSetSingleIndexForType(int typecode) |
FsIndex_singletype<TOP> |
getNonSetSingleIndexForUsedType(int i) |
Set<TOP> |
getReindexedFSs() |
TypeSystemImpl |
getTypeSystemImpl() |
Set<TOP> |
getUpdatedFSs(Set<TOP> items) |
boolean |
isCommitted()
Check if this instance has been committed.
|
boolean |
isModified() |
void |
ll_addFS(int fsRef)
Add a FS reference to all appropriate indexes in the repository.
|
void |
ll_addFS(int fsRef,
boolean doChecks)
Add a FS reference to all appropriate indexes in the repository.
|
<T extends FeatureStructure> |
ll_getAllIndexedFS(Type type) |
<T extends FeatureStructure> |
ll_getIndex(String indexName)
Get an index by its name.
|
<T extends FeatureStructure> |
ll_getIndex(String indexName,
int typeCode)
Get an index by a name and type.
|
Iterator<LowLevelIndex> |
ll_getIndexes()
Get all indexes in this repository as low level indexes
|
void |
ll_removeFS(int fsRef)
Remove a FS reference from all indexes in the repository.
|
void |
removeAllExcludingSubtypes(Type type)
Remove all instances of a particular type (but not its subtypes) from all indexes
|
void |
removeAllIncludingSubtypes(Type type)
Remove all instances of a particular type (including its subtypes) from all indexes
|
void |
removeFS(FeatureStructure fs)
Remove a feature structure from all indexes in the repository.
|
void |
removeFS(int fsRef) |
void |
removeIndex(String label)
just for testing purposes
removes the named index
Also removes indexes for all subtypes.
|
Stream<FsIndex_singletype<TOP>> |
streamNonEmptyIndexes(Class<? extends TOP> clazz) |
Stream<FsIndex_singletype<TOP>> |
streamNonEmptyIndexes(Type type)
Stream instances of all of the non-empty indexes themselves
|
String |
toString() |
void |
walkIndexedFSs(Consumer<TOP> action)
For this view, walk the indexed FSs in arbitrary order.
|
void |
walkSortedIndexedFSs(Consumer<TOP> action)
For this view, walk the indexed FSs, sorted by id
(e.g.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAllIndexedFS, removeAllExcludingSubtypes, removeAllIncludingSubtypes
public static final boolean ITEM_ADDED_TO_INDEX
public static final boolean ITEM_REMOVED_FROM_INDEX
public static final boolean V2_ANNOTATION_COMPARE_TYPE_ORDER
public static final int DEFAULT_INDEX_SIZE
public static final boolean SKIP_BAG_INDEXES
public static final boolean INCLUDE_BAG_INDEXES
public static final String ALLOW_DUP_ADD_TO_INDEXES
public static final String DISABLE_ENHANCED_WRONG_INDEX
public boolean createIndex(FSIndexComparator comp, String label, int indexType) throws CASAdminException
FSIndexRepositoryMgr
createIndex
in interface FSIndexRepositoryMgr
comp
- The comparator for the new index.label
- The name of the new index.indexType
- The kind of index (sorted, set, bag).false
iff an index with the samelabel
already exists.CASAdminException
- If the repository is locked (after calling commit()
).FSIndexRepositoryMgr.createIndex(FSIndexComparator, String)
public <T extends FeatureStructure> boolean createIndexNoQuestionsAsked(FSIndexComparator comp, String label, int indexType)
T
- -comp
- -label
- -indexType
- -public void removeIndex(String label)
label
- the name of the index to removepublic void flush()
public void commit()
FSIndexRepositoryMgr
commit
in interface FSIndexRepositoryMgr
FSIndexRepositoryMgr.commit()
public LinearTypeOrder getDefaultTypeOrder()
FSIndexRepositoryMgr
getDefaultTypeOrder
in interface FSIndexRepositoryMgr
public LinearTypeOrderBuilder getDefaultOrderBuilder()
FSIndexRepositoryMgr
getDefaultOrderBuilder
in interface FSIndexRepositoryMgr
public Iterator<FSIndex<TOP>> getIndexes()
FSIndexRepository
getIndexes
in interface FSIndexRepository
FSIndexRepository.getIndexes()
public Iterator<LowLevelIndex> ll_getIndexes()
FSIndexRepository
ll_getIndexes
in interface FSIndexRepository
public Iterator<String> getLabels()
FSIndexRepository
getLabels
in interface FSIndexRepository
FSIndexRepository.getLabels()
public <T extends FeatureStructure> Iterator<String> getLabels(FSIndexComparator comp)
T
- type of Feature Structurecomp
- The comparator.public <T extends FeatureStructure> FSIndex<T> getIndex(String label, Type type)
FSIndexRepository
getIndex
in interface FSIndexRepository
T
- The Java class associated with the typelabel
- The name of the index.type
- A subtype of the type of the index.null
if an index with that name doesn't exist.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
public <T extends FeatureStructure> LowLevelIndex<T> getIndex(String label)
FSIndexRepository
getIndex
in interface FSIndexRepository
T
- the Java class associated with the top-most type of the indexlabel
- The name of the index.label
, or null
if no such index
is defined.FSIndexRepository.getIndex(String)
public void removeAllExcludingSubtypes(Type type)
removeAllExcludingSubtypes
in interface FSIndexRepository
type
- -public void removeAllIncludingSubtypes(Type type)
removeAllIncludingSubtypes
in interface FSIndexRepository
type
- Type to remove (including all its subtypes) from this particular view.public FSIndexComparator createComparator()
FSIndexRepositoryMgr
createComparator
in interface FSIndexRepositoryMgr
FSIndexRepositoryMgr.createComparator()
public boolean isCommitted()
FSIndexRepositoryMgr
isCommitted
in interface FSIndexRepositoryMgr
true
iff this instance has been committed.FSIndexRepositoryMgr.isCommitted()
public boolean createIndex(FSIndexComparator comp, String label) throws CASAdminException
FSIndexRepositoryMgr
createIndex
in interface FSIndexRepositoryMgr
comp
- The comparator for the new index.label
- The name of the new index.false
iff an index with the samelabel
already exists.CASAdminException
- If the repository is locked (after calling commit()
).FSIndexRepositoryMgr.createIndex(org.apache.uima.cas.admin.FSIndexComparator,
java.lang.String)
public void walkIndexedFSs(Consumer<TOP> action)
action
- the action to do on each FSpublic void walkSortedIndexedFSs(Consumer<TOP> action)
action
- -public FsIndex_singletype<TOP> getNonSetSingleIndexForType(int typecode)
public FsIndex_singletype<TOP> getNonSetSingleIndexForUsedType(int i)
public void addFS(int fsRef)
public void ll_addFS(int fsRef)
LowLevelIndexRepository
ll_addFS
in interface LowLevelIndexRepository
fsRef
- The FS reference to be added to the repository. If fsRef
is not a valid
FS reference, the subsequent behavior of the system is undefined.public void ll_removeFS(int fsRef)
LowLevelIndexRepository
ll_removeFS
in interface LowLevelIndexRepository
fsRef
- The FS reference to be removed from the indexes.public <T extends FeatureStructure> void addFS(T fs)
FSIndexRepository
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 call
removeFS()
on the FS, change the feature values, then call
addFS()
again.
addFS
in interface FSIndexRepository
T
- the generic type of the FeatureStructurefs
- The FS to be added.FSIndexRepository.addFS(org.apache.uima.cas.FeatureStructure)
public void removeFS(FeatureStructure fs)
FSIndexRepository
removeFS
in interface FSIndexRepository
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.FSIndexRepository.removeFS(org.apache.uima.cas.FeatureStructure)
public void removeFS(int fsRef)
public LinearTypeOrderBuilder createTypeSortOrder()
FSIndexRepositoryMgr
createTypeSortOrder
in interface FSIndexRepositoryMgr
public <T extends FeatureStructure> LowLevelIndex<T> ll_getIndex(String indexName)
LowLevelIndexRepository
ll_getIndex
in interface LowLevelIndexRepository
T
- type of Feature StructureindexName
- The name of the index.null
if no such index exists.public <T extends FeatureStructure> LowLevelIndex<T> ll_getIndex(String indexName, int typeCode)
LowLevelIndexRepository
ll_getIndex
in interface LowLevelIndexRepository
T
- type of Feature StructureindexName
- The name of the index.typeCode
- The code of the desired subtype.null
if no such index exists.public final void ll_addFS(int fsRef, boolean doChecks)
LowLevelIndexRepository
ll_addFS
in interface LowLevelIndexRepository
fsRef
- The FS reference to be added to the repository. If fsRef
is not a valid
FS reference, the subsequent behavior of the system is undefined.doChecks
- Check if the FS reference argument is a valid reference.public <T extends TOP> void addback(T fs)
public <T extends FeatureStructure> LowLevelIterator<T> ll_getAllIndexedFS(Type type)
public <T extends FeatureStructure> LowLevelIterator<T> getAllIndexedFS(Type type)
FSIndexRepository
getAllIndexedFS
in interface FSIndexRepository
T
- The Java class associated with aTypetype
- The typeaType
and its subtypes, in no particular order.public Collection<TOP> getIndexedFSs()
FSIndexRepository
getIndexedFSs
in interface FSIndexRepository
public <T extends TOP> Collection<T> getIndexedFSs(Class<T> clazz)
FSIndexRepository
getIndexedFSs
in interface FSIndexRepository
T
- The Java class associated with typeclazz
- The JCas class corresponding to the typepublic <T extends TOP> Collection<T> getIndexedFSs(Type type)
FSIndexRepository
getIndexedFSs
in interface FSIndexRepository
T
- The Java class associated with typetype
- the type of Feature Structures to include (including subtypes)public Stream<FsIndex_singletype<TOP>> streamNonEmptyIndexes(Type type)
type
- - the type to filter the indexes withpublic Stream<FsIndex_singletype<TOP>> streamNonEmptyIndexes(Class<? extends TOP> clazz)
public boolean isModified()
public Comparator<TOP> getAnnotationFsComparator(FSComparators withId, FSComparators withTypeOrder)
public Comparator<TOP> getAnnotationFsComparatorWithoutId()
public <T extends FeatureStructure> org.apache.uima.cas.impl.FsIndex_iicp<T> getIndexBySpec(int typeCode, int indexingStrategy, FSIndexComparatorImpl comp)
T
- type of Feature StructuretypeCode
- -indexingStrategy
- -comp
- -public TypeSystemImpl getTypeSystemImpl()
public CASImpl getCasImpl()
Copyright © 2006–2021 The Apache Software Foundation. All rights reserved.