[ 
https://issues.apache.org/jira/browse/UIMA-4146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14241084#comment-14241084
 ] 

Marshall Schor commented on UIMA-4146:
--------------------------------------

Thanks for expanding on this :-).  I've been too bogged down in getting the new 
stuff to work (and along the way learning the details of the indexing / 
iterating / deserializing code) to focus more broadly....

The snapshot stuff I want to work for both non-JCas and JCas approaches.  
Because UIMA Core already has support for the extended-for for FSIndex impl,, 
I'm just piggy-backing on top of that. If you want "snapshot" style, you would:
{code:java}
// instead of
for (AnnotationFS : cas.getAnnotationIndex(type)) { ... }
// you would write
for (AnnotationFS : cas.getAnnotationIndex(type).withSnapshotIterators()) { ... 
}
{code}

I think the difference vs the "select" approach might be that select 
materializes (as actual Java Objects) all the FSs before the iteration starts, 
while the snapshot stuff doesn't - it is just "copying" the index (as a set of 
IntVectors), although it is converting the "Set" form to a "Sorted" form 
internally (which is more efficient and ok because this special index is 
read-only).

I haven't considered approaches to make things more capable for Generics, 
although I've seen some examples.  That sounds like a good extension - maybe 
for the next release after this one...  I think that (at least for me) this 
might take some "quality thought time" which I'm short of right now :-)

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

Reply via email to