[
https://issues.apache.org/jira/browse/UIMA-4146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14240301#comment-14240301
]
Richard Eckart de Castilho commented on UIMA-4146:
--------------------------------------------------
Well...
UIMA Core currently has a quite limited approach to using generics, e.g. the
indexes use "AnnotationFS" instead of "MyAnnotation".
Your post suggests that you might want to introduce a new index API that works
on JCas rather than on CAS level.
UIMA Core has a CAS-based API supporting extended for-loops already (FSIndex
extends Iterable and FSIterator extends Iterator)
{noformat}
for (AnnotationFS : cas.getAnnotationIndex(type)) { ... }
{noformat}
uimaFIT offers a JCas-based type-safe API that looks like this:
{noformat}
for (MyAnnotation : select(cas, MyAnnotation.class)) { ... }
{noformat}
However, this doesn't operate on specific indexes, rather on the generic
annotation index or potentially even on all indexed FSes.
You might get some inspiration from these classes:
{noformat}
org.apache.uima.fit.util.JCasUtil
org.apache.uima.fit.util.FSCollectionFactory<T>
{noformat}
... and maybe also to some degree from this one, although it's not type-safe,
because it doesn't use JCas:
{noformat}
org.apache.uima.fit.util.CasUtil
{noformat}
But actually, introducing a JCas API for indexes would probably be another
issue unrelated to the support for snapshots, right?
> Support Snapshot iterators for FSIndexes
> ----------------------------------------
>
> Key: UIMA-4146
> URL: https://issues.apache.org/jira/browse/UIMA-4146
> Project: UIMA
> Issue Type: New Feature
> Components: Core Java Framework
> Reporter: Marshall Schor
> Assignee: Marshall Schor
> Fix For: 2.7.0SDK
>
>
> Implementing "protectIndices" could have a consequence that some updated FSs
> could be removed from the indices by the framework, and addedback later. If
> the user code were iterating they might get unexpected
> ConcurrentModificationExceptions because of this.
> Extend the iterators to include "snapshot" iterators, that take a snapshot of
> the index contents at iterator creation time, and then use that to iterate
> over; this allows the iterator to avoid ConcurrentModificationExceptions.
> Do this in a manner to continue to support the "extended for" style of
> iterating, where you can write
> {code:java}
> for (MyAnnotation : fsIndexProducingSnapshotIterators) { ... }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)