org.apache.uima.cas.impl

## Class FsIndex_snapshot<T extends FeatureStructure>

- java.lang.Object
- - java.util.AbstractCollection<T>
  - - org.apache.uima.cas.impl.FsIndex_snapshot<T>

- All Implemented Interfaces:
    Iterable<T>, Collection<T>, Comparator<FeatureStructure>, FSIndex<T>, LowLevelIndex<T>

      public class FsIndex_snapshot<T extends FeatureStructure>
      extends AbstractCollection<T>
      implements LowLevelIndex<T>, Comparator<FeatureStructure>

  Implementation of light-weight wrapper of normal indexes, which support special kinds of iterators base on the setting of IteratorExtraFunction

- - ### Field Summary

    - ### Fields inherited from interface org.apache.uima.cas.impl.LowLevelIndex

      `FS_ID_COMPARATOR, IS_ORDERED, IS_TYPE_ORDER`

    - ### Fields inherited from interface org.apache.uima.cas.FSIndex

      `BAG_INDEX, DEFAULT_BAG_INDEX, SET_INDEX, SORTED_INDEX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FsIndex_snapshot(org.apache.uima.cas.impl.FsIndex_iicp<T> wrapped, Comparator<TOP> comparatorWithoutId, Comparator<TOP> comparatorTypeWithoutId)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compare(FeatureStructure o1, FeatureStructure o2)` Compare two feature structures according to the ordering relation of the index.
    `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.
    `T` | `find(FeatureStructure fs)` Find an entry in the index "equal to" the given feature structure according to the comparators specified for this index.
    `CASImpl` | `getCasImpl()`
    `Comparator<TOP>` | `getComparator()`
    `FSIndexComparator` | `getComparatorForIndexSpecs()` This is **NOT** a comparator for Feature Structures, but rather something that compares two comparator specifications
    `int` | `getIndexingStrategy()` Return the indexing strategy.
    `Type` | `getType()` Return the type of feature structures this index contains.
    `boolean` | `isSorted()`
    `LowLevelIterator<T>` | `iterator()` Return an iterator over the index.
    `LowLevelIterator<T>` | `iterator(boolean orderNotNeeded, boolean ignoreType)` Internal use, used by select framework.
    `int` | `ll_compare(int ref1, int ref2)` Compare two Feature structures, referred to by IDs
    `LowLevelIterator<T>` | `ll_iterator(boolean ambiguous)` Get a low-level, FS reference iterator.
    `int` | `ll_maxAnnotSpan()`
    `int` | `size()` Return the number of feature structures in this index.
    `FSIndex<T>` | `withSnapshotIterators()` Creates a shared copy of this FSIndex configured to produce snapshot iterators that don't throw ConcurrentModificationExceptions.

    - ### Methods inherited from class java.util.AbstractCollection

      `add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString`

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

      `flush, getIntIterator, getSubIndex, getSubIndex, ll_iterator, select, select, select, select, select`

    - ### Methods inherited from interface org.apache.uima.cas.FSIndex

      `iterator, stream, subType, subType`

    - ### Methods inherited from interface java.util.Collection

      `add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, toArray, toArray`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

    - ### Methods inherited from interface java.util.Comparator

      `comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

- - ### Constructor Detail

    - #### FsIndex_snapshot

          public FsIndex_snapshot(org.apache.uima.cas.impl.FsIndex_iicp<T> wrapped,
                                  Comparator<TOP> comparatorWithoutId,
                                  Comparator<TOP> comparatorTypeWithoutId)

  - ### Method Detail

    - #### getType

          public Type getType()

      Description copied from interface: `FSIndex`
      Return the type of feature structures this index contains.
      Specified by:
        `getType` in interface `FSIndex<T extends FeatureStructure>`
      Returns:
        The type of feature structures in this index.

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

      Specified by:
        `contains` in interface `FSIndex<T extends FeatureStructure>`
      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.

    - #### find

          public T find(FeatureStructure fs)

      Description copied from interface: `FSIndex`
      Find an entry in the index "equal to" the given feature structure according to the comparators specified for this index. Note that this is in general not the same as feature structure identity. For BAG indexes, it is identity, for others it means the found feature structure compares equal with the parameter in terms of the defined comparators for the index. If there are multiple different FSs in the index which compare equal with the given feature structure, an arbitrary one is returned. This differs from the moveTo(fs) operation which guarantees to move to the first feature structure occurring in the index in this case.
      Specified by:
        `find` in interface `FSIndex<T extends FeatureStructure>`
      Parameters:
        `fs` - A Feature Structure used a template to match with the Feature Structures in the index. It must have the keys needed to do the compare as specified for the index that it's in.
      Returns:
        A FS equal to the template argument, or `null` if no such FS exists.
      See Also:
        `FSIterator.moveTo(FeatureStructure)`

    - #### 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 interface `Iterable<T extends FeatureStructure>`
      Specified by:
        `iterator` in interface `Collection<T extends FeatureStructure>`
      Specified by:
        `iterator` in interface `FSIndex<T extends FeatureStructure>`
      Specified by:
        `iterator` in interface `LowLevelIndex<T extends FeatureStructure>`
      Specified by:
        `iterator` in class `AbstractCollection<T extends FeatureStructure>`
      Returns:
        An FSIterator positioned at the beginning, or an invalid iterator.

    - #### 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.
      Specified by:
        `iterator` in interface `LowLevelIndex<T extends FeatureStructure>`
      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.

    - #### getIndexingStrategy

          public int getIndexingStrategy()

      Description copied from interface: `FSIndex`
      Return the indexing strategy.
      Specified by:
        `getIndexingStrategy` in interface `FSIndex<T extends FeatureStructure>`
      Returns:
        One of `SORTED_INDEX`, `BAG_INDEX` or `SET_INDEX`.

    - #### withSnapshotIterators

          public FSIndex<T> withSnapshotIterators()

      Description copied from interface: `FSIndex`
      Creates a shared copy of this FSIndex configured to produce snapshot iterators that don't throw ConcurrentModificationExceptions.
      Specified by:
        `withSnapshotIterators` in interface `FSIndex<T extends FeatureStructure>`
      Returns:
        a light-weight copy of this FSIndex, configured such that any iterator created using it will be a snapshot iterator - one where a snapshot is made of the state of the index at the time the iterator is created, and where subsequent modifications to the underlying index are allowed, but don't affect the iterator (which iterates over the read-only snapshot). Iterators produced with this won't throw ConcurrentModificationExceptions.

    - #### size

          public int size()

      Description copied from interface: `FSIndex`
      Return the number of feature structures in this index.
      Specified by:
        `size` in interface `Collection<T extends FeatureStructure>`
      Specified by:
        `size` in interface `FSIndex<T extends FeatureStructure>`
      Specified by:
        `size` in class `AbstractCollection<T extends FeatureStructure>`
      Returns:
        The number of FSs in this index.

    - #### compare

          public int compare(FeatureStructure o1,
                             FeatureStructure o2)

      Description copied from interface: `FSIndex`
      Compare two feature structures according to the ordering relation of the index. If the input feature structures are not of the type of the index or a supertype, the result is undefined. Because the indexes compare might use only features defined in supertypes, the arguments being compared could be supertypes of the indexed type.
      Specified by:
        `compare` in interface `Comparator<FeatureStructure>`
      Specified by:
        `compare` in interface `FSIndex<T extends FeatureStructure>`
      Parameters:
        `o1` - the first Feature Structure to compare
        `o2` - the second Feature Structure to compare
      Returns:
        `-1` if `fs1 < fs2`; `0` if `fs1 = fs2`; `1` else.

    - #### ll_iterator

          public LowLevelIterator<T> ll_iterator(boolean ambiguous)

      Description copied from interface: `LowLevelIndex`
      Get a low-level, FS reference iterator. This iterator can be disambiguated. This means that only non-overlapping annotations will be returned. Non-annotation FSs will be filtered in this mode.
      Specified by:
        `ll_iterator` in interface `LowLevelIndex<T extends FeatureStructure>`
      Parameters:
        `ambiguous` - When set to `false`, iterator will be disambiguated.
      Returns:
        An iterator for this index.

    - #### ll_compare

          public int ll_compare(int ref1,
                                int ref2)

      Description copied from interface: `LowLevelIndex`
      Compare two Feature structures, referred to by IDs
      Specified by:
        `ll_compare` in interface `LowLevelIndex<T extends FeatureStructure>`
      Parameters:
        `ref1` - -
        `ref2` - -
      Returns:
        -

    - #### getCasImpl

          public CASImpl getCasImpl()

      Specified by:
        `getCasImpl` in interface `LowLevelIndex<T extends FeatureStructure>`
      Returns:
        a CAS View associated with this iterator

    - #### getComparator

          public Comparator<TOP> getComparator()

      Specified by:
        `getComparator` in interface `LowLevelIndex<T extends FeatureStructure>`
      Returns:
        a comparator used by this index to compare Feature Structures For sets, the equal is used to determine set membership For sorted, the comparator is the sort order (this comparator is without the ID)

    - #### getComparatorForIndexSpecs

          public FSIndexComparator getComparatorForIndexSpecs()

      Description copied from interface: `LowLevelIndex`
      This is **NOT** a comparator for Feature Structures, but rather something that compares two comparator specifications
      Specified by:
        `getComparatorForIndexSpecs` in interface `LowLevelIndex<T extends FeatureStructure>`
      Returns:
        -

    - #### ll_maxAnnotSpan

          public int ll_maxAnnotSpan()

      Specified by:
        `ll_maxAnnotSpan` in interface `LowLevelIndex<T extends FeatureStructure>`
      Returns:
        for annotation indexes, an conservative estimate the maximum span between begin and end The value may be larger than actual.

    - #### isSorted

          public boolean isSorted()

      Specified by:
        `isSorted` in interface `LowLevelIndex<T extends FeatureStructure>`
      Returns:
        true if the index is sorted

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