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 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. There are 2 kinds of cover classes: If JCas is not being used, or if there is no JCas cover class defined for a type, then the Java class FeatureStructureImplC is used as the cover class. If the JCas is being used, then the JCas cover type (a subtype of TOP) is used as the cover class. Both of these classes inherit from FeatureStructureImpl (an abstract class) Both of these classes implement the common interface FeatureStructure. 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 cover types (JCas and non-JCas). 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 and Description
    --- | ---
    `static class` | `FSIndexRepositoryImpl.IteratorExtraFunction` Kinds of extra functions for iterators

  - ### Field Summary

    Fields
    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` | `IS_ALLOW_DUP_ADD_2_INDEXES`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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, String label)` Create a new sorted index.
    `boolean` | `createIndex(FSIndexComparator comp, String label, int indexType)` Create a new index.
    `boolean` | `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.
    `int[]` | `getAddedFSs()`
    `<T extends FeatureStructure> FSIterator<T>` | `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()`
    `<T extends FeatureStructure> FSIndex<T>` | `getIndex(String label)` Retrieve an index according to a label.
    `<T extends FeatureStructure> FSIndex<T>` | `getIndex(String label, Type type)` Retrieve an index according to a label and a type.
    `int[]` | `getIndexedFSs()` For one particular view (the one associated with this instance of FsIndexRepositoryImpl), return an array containing all FSs in any defined index, in this view.
    `Iterator<FSIndex<FeatureStructure>>` | `getIndexes()` Get all indexes in this repository.
    `int` | `getIndexSize(Type type)`
    `org.apache.uima.internal.util.IntPointerIterator` | `getIntIteratorForIndex(String label)`
    `org.apache.uima.internal.util.IntPointerIterator` | `getIntIteratorForIndex(String label, Type type)`
    `Iterator<String>` | `getLabels()` Get all labels for all indexes.
    `Iterator<String>` | `getLabels(FSIndexComparator comp)` Get the labels for a specific comparator.
    `int[]` | `getReindexedFSs()`
    `int[]` | `getUpdatedFSs(org.apache.uima.internal.util.PositiveIntSet items)`
    `boolean` | `isCommitted()` Check if this instance has been committed.
    `boolean` | `isInSetOrSortedIndexInThisView(int fsAddr)` This is used to see if a FS which has a key feature being modified could corrupt an index in this view.
    `boolean` | `isModified()`
    `void` | `ll_addback(int fsRef, int count)`
    `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.
    `LowLevelIterator` | `ll_getAllIndexedFS(Type type)`
    `LowLevelIndex` | `ll_getIndex(String indexName)` Get an index by its name.
    `LowLevelIndex` | `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)`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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

    - #### ALLOW_DUP_ADD_TO_INDEXES

          public static final 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

    - #### IS_ALLOW_DUP_ADD_2_INDEXES

          public static final boolean IS_ALLOW_DUP_ADD_2_INDEXES

    - #### DISABLE_ENHANCED_WRONG_INDEX

          public static final String DISABLE_ENHANCED_WRONG_INDEX

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### flush

          public void flush()

      Reset all indexes, in one view.

    - #### 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,
                                     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 same`label` already exists.
      Throws:
        `CASAdminException` - If the repository is locked (after calling `commit()`).
      See Also:
        `FSIndexRepositoryMgr.createIndex(FSIndexComparator, String)`

    - #### createIndexNoQuestionsAsked

          public boolean createIndexNoQuestionsAsked(FSIndexComparator comp,
                                                     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:
        -

    - #### getIndexes

          public 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()`

    - #### ll_getIndexes

          public Iterator<LowLevelIndex> ll_getIndexes()

      Description copied from interface: `FSIndexRepository`
      Get all indexes in this repository as low level indexes
      Specified by:
        `ll_getIndexes` in interface `FSIndexRepository`
      Returns:
        All indexes.

    - #### getLabels

          public Iterator<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 Iterator<String> getLabels(FSIndexComparator comp)

      Get the labels for a specific comparator.
      Parameters:
        `comp` - The comparator.
      Returns:
        An iterator over the labels.

    - #### getIndex

          public <T extends FeatureStructure> FSIndex<T> getIndex(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. Generics: T is the associated Java cover class for the type.
      Specified by:
        `getIndex` in interface `FSIndexRepository`
      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 `null` if an index with that name doesn't exist.
      See Also:
        `FSIndexRepository.getIndex(String, Type)`

    - #### getIndex

          public <T extends FeatureStructure> FSIndex<T> getIndex(String label)

      Description copied from interface: `FSIndexRepository`
      Retrieve 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:
        `getIndex` in interface `FSIndexRepository`
      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`, or `null` if no such index is defined.
      See Also:
        `FSIndexRepository.getIndex(String)`

    - #### getIntIteratorForIndex

          public org.apache.uima.internal.util.IntPointerIterator getIntIteratorForIndex(String label)

    - #### getIntIteratorForIndex

          public org.apache.uima.internal.util.IntPointerIterator getIntIteratorForIndex(String label,
                                                                                         Type type)

    - #### getIndexSize

          public int getIndexSize(Type type)

    - #### removeAllExcludingSubtypes

          public void removeAllExcludingSubtypes(Type type)

      Remove all instances of a particular type (but not its subtypes) from all indexes
      Specified by:
        `removeAllExcludingSubtypes` in interface `FSIndexRepository`
      Parameters:
        `type` - -

    - #### removeAllIncludingSubtypes

          public void removeAllIncludingSubtypes(Type type)

      Remove all instances of a particular type (including its subtypes) from all indexes
      Specified by:
        `removeAllIncludingSubtypes` in interface `FSIndexRepository`
      Parameters:
        `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,
                                     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 same`label` 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()

      For one particular view (the one associated with this instance of FsIndexRepositoryImpl), return an array containing all FSs in any defined index, in this view. This is intended to be used for serialization. Note that duplicate entries are removed. It used to be that the items were sorted by fs addr, but that only happens if the dedup code runs 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.
      Returns:
        an array containing all FSs in any defined index, in this view.

    - #### 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(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(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_addback

          public void ll_addback(int fsRef,
                                 int count)

    - #### 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.

    - #### ll_getAllIndexedFS

          public LowLevelIterator ll_getAllIndexedFS(Type type)

    - #### getAllIndexedFS

          public <T extends FeatureStructure> FSIterator<T> getAllIndexedFS(Type type)

      Description copied from interface: `FSIndexRepository`
      Gets an iterator over all indexed FeatureStructures of the specified Type (and any of its subtypes). The elements are returned in arbitrary order, and duplicates (if they exist) are not removed. Generics: T is the Java class for aType.
      Specified by:
        `getAllIndexedFS` in interface `FSIndexRepository`
      Type Parameters:
        `T` - The Java class associated with aType
      Parameters:
        `type` - The type
      Returns:
        An iterator that returns all indexed FeatureStructures of type `aType` and its subtypes, in no particular order.

    - #### isInSetOrSortedIndexInThisView

          public boolean isInSetOrSortedIndexInThisView(int fsAddr)

      This is used to see if a FS which has a key feature being modified could corrupt an index in this view. It returns true if found (sometimes it returns true, even if strictly speaking, there is no chance of corruption - see below) It does this by seeing if this FS is indexed by one or more Set or Sorted indexes. If found in the first Sorted index encountered, return true Else, if found in any Set index, return true, otherwise false To speed up the 2nd case, when there are more than one Set indexes, we do an approximation if there are any bag indexes: we check if found in the first bag index encountered -- return true if found This is an approximation in that it could be that none of the Set indexes contain that FS, but it is in the bag index. So, this method can sometimes return true incorrectly. If type is subtype of annotation, can just test the built-in Annotation index.
      Parameters:
        `fsAddr` - the FS to see if it is in some index that could be corrupted by a key feature value change
      Returns:
        true if this fs is found in a Set or Sorted index.

    - #### getUpdatedFSs

          public int[] getUpdatedFSs(org.apache.uima.internal.util.PositiveIntSet items)

    - #### getAddedFSs

          public int[] getAddedFSs()

    - #### getDeletedFSs

          public int[] getDeletedFSs()

    - #### getReindexedFSs

          public int[] getReindexedFSs()

    - #### isModified

          public boolean isModified()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2006–2021 The Apache Software Foundation. All rights reserved.