Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.uima.cas
Interface FSIndex

All Known Subinterfaces:
  AnnotationIndex

    public interface FSIndex

Feature structure index access interface.

Notice that each feature structure index uses its own ordering relation that will usually be different from index to index. In particular, equality with respect to the index ordering will in general not imply object identity for the feature structures.

We currently support three different kinds of indexes: sorted, set and bag indexes. The default index is a sorted index. In a sorted index, all FSs that are commited are entered, even if they are duplicates of already existing FSs. The index is sorted in the sense that iterators will output FSs in sorted order according to the comparator for that index. The order of FSs that are equal wrt the comparator is arbitrary but fixed. That is, if you iterate over the same index several times, you will see the same relative order of FSs every time. We also guarantee that reverse iterators will produce exactly the reverse sequence of forward iteration.

A set index will contain no duplicates of the same type, where a duplicate is defined by the indexing comparator. That is, if you commit two feature structures of the same type that are equal wrt the indexing comparator, only the first one will be entered into the index. Note that you can still have duplicates wrt the indexing order if they are of a different type. A set index is not guaranteed to be sorted.

A bag index finally simply stores everything, without any guaranteed order. Our current implementation works such that for any two FSs of the same type, they will be returned in the order in which they are committed (FIFO style). Note that any operation like find() or FSIterator.moveTo() will not produce useful results on bag indexes, since bag indexes do not honor comparators. Only use a bag index if you want very fast adding and will have to iterate over the whole index anyway.

Field Summary
`static int` | `BAG_INDEX` Indexing strategy: bag index.
`static int` | `DEFAULT_BAG_INDEX` Special indexes used by the framework to implement `FSIndexRepository.getAllIndexedFS(Type)`.
`static int` | `SET_INDEX` Indexing strategy: set index.
`static int` | `SORTED_INDEX` Indexing strategy: sorted index.

Method Summary
`int` | `compare(FeatureStructure fs1, FeatureStructure fs2)` 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 ordering of the index.
`FeatureStructure` | `find(FeatureStructure fs)` Find an entry in the index equal to the given feature structure according to the ordering of the index.
`int` | `getIndexingStrategy()` Return the indexing strategy.
`Type` | `getType()` Return the type of feature structures this index contains.
`FSIterator` | `iterator()` Return an iterator over the index.
`FSIterator` | `iterator(FeatureStructure fs)` Return an iterator over the index.
`int` | `size()` Return the number of feature strucures in this index.

Field Detail

### SORTED_INDEX

    static final int SORTED_INDEX

  Indexing strategy: sorted index. A sorted index contains all elements, including duplicates. Iterators over sorted indexes will return elements in sorted order.

  See Also:
    Constant Field Values

### SET_INDEX

    static final int SET_INDEX

  Indexing strategy: set index. A set index contains no duplicates of the same type, where a duplicate is defined by the indexing comparator. A set index is not guaranteed to be sorted.

  See Also:
    Constant Field Values

### BAG_INDEX

    static final int BAG_INDEX

  Indexing strategy: bag index. A bag index contains all elements, in no particular order.

  See Also:
    Constant Field Values

### DEFAULT_BAG_INDEX

    static final int DEFAULT_BAG_INDEX

  Special indexes used by the framework to implement `FSIndexRepository.getAllIndexedFS(Type)`. Not user-definable.

  See Also:
    Constant Field Values

Method Detail

### size

    int size()

  Return the number of feature strucures in this index.

  Returns:
    The number of FSs in this index.

### getType

    Type getType()

  Return the type of feature structures this index contains.

  Returns:
    The type of feature structures in this index.

### contains

    boolean contains(FeatureStructure fs)

  Check if the index contains an element equal to the given feature structure according to the ordering of the index. Note that this is in general not the same as feature structure identity.

  Parameters:
    `fs` - The FS we're looking for.
  Returns:
    `true` iff the index contains such an element.

### find

    FeatureStructure find(FeatureStructure fs)

  Find an entry in the index equal to the given feature structure according to the ordering of the index. Note that this is in general not the same as feature structure identity.

  Parameters:
    `fs` - The FS we're looking for.
  Returns:
    A FS equal to `fs`, or `null` if no such FS exists.
  See Also:
    `FSIterator.moveTo(FeatureStructure)`

### compare

    int compare(FeatureStructure fs1,
                FeatureStructure fs2)

  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, the result is undefined.

  Returns:
    `-1` if `fs1 < fs2`; `0` if `fs1 = fs2`; `1` else.

### iterator

    FSIterator iterator()

  Return an iterator over the index. The iterator will be set to the start position of the index.

  Returns:
    An iterator over the index.

### iterator

    FSIterator iterator(FeatureStructure fs)

  Return an iterator over the index. The position of the iterator will be set such that the feature structure returned by a call to the iterator's `get()` method is greater than or equal to `fs`, and any previous FS is less than `FS`. If no such position exists, the iterator will be invalid.

  Parameters:
    `fs` - The feature structure at which the iterator should be positioned.
  Returns:
    An iterator positioned at `fs`, if it exists. An invalid iterator, else.

### getIndexingStrategy

    int getIndexingStrategy()

  Return the indexing strategy.

  Returns:
    One of `SORTED_INDEX`, `BAG_INDEX` or `SET_INDEX`.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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