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

Marshall Schor edited comment on UIMA-5603 at 10/5/17 7:57 PM:
---------------------------------------------------------------

I'm undoing the change to permit the iterator to be used in the extended-for, 
due to the issue raised by Richard.  Instead, I'm adding new methods to the 3 
interfaces (CAS, JCas, and FSIndexRepository): getIndexedFSs(Type or 
JCas.class), which return unmodifiable, unordered collections of the indexed 
Feature Structures.  These collections are light-weight, and don't copy the 
indexes themselves.  They can be use in the extended-for construct, and use the 
same copy-on-write mechanism that iterators use, so you can update the indexes 
if you wish while using these.  Some internal use of the getAllIndexedFS 
methods (which returned FSIterators) are being switched to use this form . 
iterator(), because it avoids copying the indexes themselves, into another 
newly created object.


was (Author: schor):
I'm undoing this change due to the issue raised by Richard.  Instead, I'm 
adding new methods to the 3 interfaces (CAS, JCas, and FSIndexRepository): 
getIndexedFSs(Type or JCas.class), which return unmodifiable, unordered 
collections of the indexed Feature Structures.  These collections are 
light-weight, and don't copy the indexes themselves.  They can be use in the 
extended-for construct, and use the same copy-on-write mechanism that iterators 
use, so you can update the indexes if you wish while using these.  Some 
internal use of the getAllIndexedFS methods (which returned FSIterators) are 
being switched to use this form . iterator(), because it avoids copying the 
indexes themselves, into another newly created object.

> uv3 add ability to do extended-for on all FSs of a type in a view
> -----------------------------------------------------------------
>
>                 Key: UIMA-5603
>                 URL: https://issues.apache.org/jira/browse/UIMA-5603
>             Project: UIMA
>          Issue Type: Improvement
>          Components: Core Java Framework
>    Affects Versions: 3.0.0SDK-alpha02
>            Reporter: Marshall Schor
>            Assignee: Marshall Schor
>            Priority: Trivial
>             Fix For: 3.0.0SDK-beta
>
>
> Forms like cas.getIndexRepository().getAllIndexedFSs(...) return an iterator. 
>  It would be nice to be able to use the returned result in an extended for :  
>  for (TOP x : cas.getInd... etc).  
> Add a new set of methods, getIndexedFSs( Type or JCas.class or nothing) to 
> CAS/JCas and FSIndexRepository interfaces, that return Collections, without 
> copying the index arrays, but just using them.  Make these copy-on-write 
> style, so subsequent updates to the UIMA indexes won't affect the collection. 
>  These can then be used in extended-for loops.
> Update internal uses of getAllIndexedFS (which does copy the indexes) to use 
> the new style.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to