org.apache.uima.cas.impl
Class FSIndexRepositoryImpl

java.lang.Object
  extended by org.apache.uima.cas.impl.FSIndexRepositoryImpl
All Implemented Interfaces:
FSIndexRepositoryMgr, FSIndexRepository, LowLevelIndexRepository

public class FSIndexRepositoryImpl
extends java.lang.Object
implements FSIndexRepositoryMgr, LowLevelIndexRepository


Field Summary
static int DEFAULT_INDEX_SIZE
          The default size of an index.
 
Method Summary
 void addFS(FeatureStructure fs)
          Add a feature structure to all appropriate indexes in the repository.
 void addFS(int fsRef)
           
 void commit()
          Commit this repository instance.
 FSIndexComparator createComparator()
          Create a new comparator to define a new index.
 boolean createIndex(FSIndexComparator comp, java.lang.String label)
          Create a new sorted index.
 boolean createIndex(FSIndexComparator comp, java.lang.String label, int indexType)
          Create a new index.
 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.).
 LinearTypeOrderBuilder createTypeSortOrder()
          Currently not useful.
 void flush()
          Reset all indexes.
 int[] getAddedFSs()
           
 FSIterator<FeatureStructure> getAllIndexedFS(Type type)
          Gets an iterator over all indexed FeatureStructures of the specified Type (and any of its subtypes).
 LinearTypeOrderBuilder getDefaultOrderBuilder()
          Get the default type order builder.
 LinearTypeOrder getDefaultTypeOrder()
          Get the default type order.
 int[] getDeletedFSs()
           
 FSIndex<FeatureStructure> getIndex(java.lang.String label)
          Retrieve an index according to a label.
 FSIndex<FeatureStructure> getIndex(java.lang.String label, Type type)
          Retrieve an index according to a label and a type.
 int[] getIndexedFSs()
          Return an array containing all FSs in any index.
 java.util.Iterator<FSIndex<FeatureStructure>> getIndexes()
          Get all indexes in this repository.
 int getIndexSize(Type type)
           
 IntPointerIterator getIntIteratorForIndex(java.lang.String label)
           
 IntPointerIterator getIntIteratorForIndex(java.lang.String label, Type type)
           
 java.util.Iterator<java.lang.String> getLabels()
          Get all labels for all indexes.
 java.util.Iterator<java.lang.String> getLabels(FSIndexComparator comp)
          Get the labels for a specific comparator.
 int[] getReindexedFSs()
           
 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.
 LowLevelIndex ll_getIndex(java.lang.String indexName)
          Get an index by its name.
 LowLevelIndex ll_getIndex(java.lang.String indexName, int typeCode)
          Get an index by a name and type.
 void ll_removeFS(int fsRef)
          Remove a FS reference from all indexes in the repository.
 void removeFS(FeatureStructure fs)
          Remove a feature structure from all indexes in the repository.
 void removeFS(int fsRef)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INDEX_SIZE

public static final int DEFAULT_INDEX_SIZE
The default size of an index.

See Also:
Constant Field Values
Method Detail

flush

public void flush()
Reset all indexes.


addFS

public void addFS(int fsRef)

commit

public void commit()
Description copied from interface: FSIndexRepositoryMgr
Commit this repository instance. No more additions will be allowed.

Specified by:
commit in interface FSIndexRepositoryMgr
See Also:
FSIndexRepositoryMgr.commit()

getDefaultTypeOrder

public LinearTypeOrder getDefaultTypeOrder()
Description copied from interface: FSIndexRepositoryMgr
Get the default type order.

Specified by:
getDefaultTypeOrder in interface FSIndexRepositoryMgr
Returns:
The default type order.

getDefaultOrderBuilder

public LinearTypeOrderBuilder getDefaultOrderBuilder()
Description copied from interface: FSIndexRepositoryMgr
Get the default type order builder.

Specified by:
getDefaultOrderBuilder in interface FSIndexRepositoryMgr
Returns:
The default type order builder.

createIndex

public boolean createIndex(FSIndexComparator comp,
                           java.lang.String label,
                           int indexType)
                    throws CASAdminException
Description copied from interface: FSIndexRepositoryMgr
Create a new index. Note: if you creata a BAG_INDEX, the comparator will be ignored.

Specified by:
createIndex in interface FSIndexRepositoryMgr
Parameters:
comp - The comparator for the new index.
label - The name of the new index.
indexType - The kind of index (sorted, set, bag).
Returns:
false iff an index with the samelabel already exists.
Throws:
CASAdminException - If the repository is locked (after calling commit()).
See Also:
FSIndexRepositoryMgr.createIndex(FSIndexComparator, String)

createIndexNoQuestionsAsked

public 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.).

Parameters:
comp -
label -
indexType -
Returns:
boolean

getIndexes

public java.util.Iterator<FSIndex<FeatureStructure>> getIndexes()
Description copied from interface: FSIndexRepository
Get all indexes in this repository.

Specified by:
getIndexes in interface FSIndexRepository
Returns:
All indexes.
See Also:
FSIndexRepository.getIndexes()

getLabels

public java.util.Iterator<java.lang.String> getLabels()
Description copied from interface: FSIndexRepository
Get all labels for all indexes.

Specified by:
getLabels in interface FSIndexRepository
Returns:
All labels.
See Also:
FSIndexRepository.getLabels()

getLabels

public java.util.Iterator<java.lang.String> getLabels(FSIndexComparator comp)
Get the labels for a specific comparator.

Parameters:
comp - The comparator.
Returns:
An iterator over the labels.

getIndex

public FSIndex<FeatureStructure> getIndex(java.lang.String label,
                                          Type type)
Description copied from interface: FSIndexRepository
Retrieve 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.

Specified by:
getIndex in interface FSIndexRepository
Parameters:
label - The name of the index.
type - A subtype of the type of the index.
Returns:
The specified, or null if an index with that name doesn't exist.
See Also:
FSIndexRepository.getIndex(String, Type)

getIndex

public FSIndex<FeatureStructure> getIndex(java.lang.String label)
Description copied from interface: FSIndexRepository
Retrieve an index according to a label.

Specified by:
getIndex in interface FSIndexRepository
Parameters:
label - The name of the index.
Returns:
The index with the name label, or null if no such index is defined.
See Also:
FSIndexRepository.getIndex(String)

getIntIteratorForIndex

public IntPointerIterator getIntIteratorForIndex(java.lang.String label)

getIntIteratorForIndex

public IntPointerIterator getIntIteratorForIndex(java.lang.String label,
                                                 Type type)

getIndexSize

public int getIndexSize(Type type)

createComparator

public FSIndexComparator createComparator()
Description copied from interface: FSIndexRepositoryMgr
Create a new comparator to define a new index.

Specified by:
createComparator in interface FSIndexRepositoryMgr
Returns:
A new comparator instance.
See Also:
FSIndexRepositoryMgr.createComparator()

isCommitted

public boolean isCommitted()
Description copied from interface: FSIndexRepositoryMgr
Check if this instance has been committed.

Specified by:
isCommitted in interface FSIndexRepositoryMgr
Returns:
true iff 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: FSIndexRepositoryMgr
Create a new sorted index.

Specified by:
createIndex in interface FSIndexRepositoryMgr
Parameters:
comp - The comparator for the new index.
label - The name of the new index.
Returns:
false iff an index with the samelabel already exists.
Throws:
CASAdminException - If the repository is locked (after calling commit()).
See Also:
FSIndexRepositoryMgr.createIndex(org.apache.uima.cas.admin.FSIndexComparator, java.lang.String)

getIndexedFSs

public int[] getIndexedFSs()
Return an array containing all FSs in any index. This is intended to be used for serialization. Note that duplicate entries in indexes will appear in the array as many times as they occur in an index. The order in which FSs occur in the array does not reflect the order in which they were added to the repository. This means that set indexes deserialized from this list may contain different but equal elements than the original index.


addFS

public void addFS(FeatureStructure fs)
Description copied from interface: FSIndexRepository
Add 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 call removeFS() on the FS, change the feature values, then call addFS() again.

Specified by:
addFS in interface FSIndexRepository
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: FSIndexRepository
Remove a feature structure from all indexes in the repository.

Specified by:
removeFS in interface FSIndexRepository
Parameters:
fs - The FS to be removed.
See Also:
FSIndexRepository.removeFS(org.apache.uima.cas.FeatureStructure)

removeFS

public void removeFS(int fsRef)

createTypeSortOrder

public LinearTypeOrderBuilder createTypeSortOrder()
Description copied from interface: FSIndexRepositoryMgr
Currently not useful.

Specified by:
createTypeSortOrder in interface FSIndexRepositoryMgr
Returns:
A new type order builder.

ll_getIndex

public LowLevelIndex ll_getIndex(java.lang.String indexName)
Description copied from interface: LowLevelIndexRepository
Get an index by its name.

Specified by:
ll_getIndex in interface LowLevelIndexRepository
Parameters:
indexName - The name of the index.
Returns:
The corresponding index, or null if no such index exists.

ll_getIndex

public LowLevelIndex ll_getIndex(java.lang.String indexName,
                                 int typeCode)
Description copied from interface: LowLevelIndexRepository
Get 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_getIndex in interface LowLevelIndexRepository
Parameters:
indexName - The name of the index.
typeCode - The code of the desired subtype.
Returns:
The corresponding index, or null if no such index exists.

ll_addFS

public final void ll_addFS(int fsRef,
                           boolean doChecks)
Description copied from interface: LowLevelIndexRepository
Add a FS reference to all appropriate indexes in the repository.

Specified by:
ll_addFS in interface LowLevelIndexRepository
Parameters:
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.

ll_addFS

public void ll_addFS(int fsRef)
Description copied from interface: LowLevelIndexRepository
Add a FS reference to all appropriate indexes in the repository.

Specified by:
ll_addFS in interface LowLevelIndexRepository
Parameters:
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.

ll_removeFS

public void ll_removeFS(int fsRef)
Description copied from interface: LowLevelIndexRepository
Remove 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_removeFS in interface LowLevelIndexRepository
Parameters:
fsRef - The FS reference to be removed from the indexes.

getAllIndexedFS

public FSIterator<FeatureStructure> getAllIndexedFS(Type type)
Description copied from interface: FSIndexRepository
Gets an iterator over all indexed FeatureStructures of the specified Type (and any of its subtypes).

Limitation: If there are no sorted or bag indexes defined for this type, but there is more than one set index defined, then this method will only return the contents of one of these set indexes (chosen arbitrarily).

Specified by:
getAllIndexedFS in interface FSIndexRepository
Parameters:
type - The type
Returns:
An iterator that returns all indexed FeatureStructures of type aType, in no particular order.

getAddedFSs

public int[] getAddedFSs()

getDeletedFSs

public int[] getDeletedFSs()

getReindexedFSs

public int[] getReindexedFSs()

isModified

public boolean isModified()


Copyright © 2010 The Apache Software Foundation. All Rights Reserved.