You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by Marshall Schor <ms...@schor.com> on 2014/12/04 17:13:34 UTC

name and style for new UIMA iterators

I'm working on providing UIMA will some new iterators that allow arbitrary index
modifications while you're iterating;  they do this by essentially "copying" the
state of the index when the iterator is created, and using that copy in a
read-only mode to do the iteration, thus allowing the original indices to be
updated while iterating (the iterator won't see those index updates).  

This supports use cases such as iterating over some FSs of some type, and
removing some of them, updating them and adding them back, etc.

I'm thinking various alternatives for specifying this kind of iterator.  To
preserve the ability of using the Java extended "for" statement:

   for (FeatureStructure fs : myIndex)

where myIndex is of type FSIndex, I'm thinking of having a new method in
FSIndex, which will produce a light-weight FSIndex object which operates like a
base FSIndex object, except that it produces these new kinds of iterators.  
This is as-opposed-to a new iterator() method, because the Iterable interface
makes use of the iterator() method...

The method to specify that the new iterators for an existing FSIndex would be
something like "withSnapshotIterators()".  You would use it like this:

   FSIndex  myNormalIndex = myIndexRepository.getIndex("myIndexName");

   FSIndex snapshotVersionOfIndex = myNormalIndex.withSnapshotIterators();

Some observations:
   The withSnapshotIterators could "update" the FSIndex object, or create a new
(lightweight) copy of it with the new configuration.
      -  Which should it do?  It seems that making a (very light-weight) copy
would be safer, so I'm leaning that way

   The forms could of course be combined:
       e.g.:   for (FeatureStructure fs :
indexRepo.getIndex("foo").withSnapshotIterators) ....

Another way of writing this is:
   with_snapshot_iterators()     There have been studies that this is easier to
read, and it seems that way to me...

The "with...." part in the name seem good (to me) because it implies you still
have an FSIndex; only the iterator part is changed (which is the case).

WDYT?

-Marshall

Re: name and style for new UIMA iterators

Posted by Richard Eckart de Castilho <re...@apache.org>.
Java code should use CamelCase. Just that there are some C-isms
in the bowels of UIMA core doesn't make it fashionable to use
underscores.

-- Richard

On 04.12.2014, at 23:14, Marshall Schor <ms...@schor.com> wrote:

> some methods in UIMA already use the underscore.  For example, there's lots of
> methods for CAS related things that are named
> ll_xxxxx
> 
> Cheers. -Marshall
> 
> On 12/4/2014 5:01 PM, Burn Lewis wrote:
>> With_underscores may be easier to read but all the other methods use
>> camelCase ... which admittedly has the lower-case I / uppercase i confusion.
>> 
>> Another alternative is to change the "safeness" of the index. e.g.
>> myIndex.setSafeIteration(true/false);
>> 
>> ~Burn


Re: name and style for new UIMA iterators

Posted by Marshall Schor <ms...@schor.com>.
some methods in UIMA already use the underscore.  For example, there's lots of
methods for CAS related things that are named
ll_xxxxx

Cheers. -Marshall

On 12/4/2014 5:01 PM, Burn Lewis wrote:
> With_underscores may be easier to read but all the other methods use
> camelCase ... which admittedly has the lower-case I / uppercase i confusion.
>
> Another alternative is to change the "safeness" of the index. e.g.
> myIndex.setSafeIteration(true/false);
>
> ~Burn
>
> On Thu, Dec 4, 2014 at 11:13 AM, Marshall Schor <ms...@schor.com> wrote:
>
>> I'm working on providing UIMA will some new iterators that allow arbitrary
>> index
>> modifications while you're iterating;  they do this by essentially
>> "copying" the
>> state of the index when the iterator is created, and using that copy in a
>> read-only mode to do the iteration, thus allowing the original indices to
>> be
>> updated while iterating (the iterator won't see those index updates).
>>
>> This supports use cases such as iterating over some FSs of some type, and
>> removing some of them, updating them and adding them back, etc.
>>
>> I'm thinking various alternatives for specifying this kind of iterator.  To
>> preserve the ability of using the Java extended "for" statement:
>>
>>    for (FeatureStructure fs : myIndex)
>>
>> where myIndex is of type FSIndex, I'm thinking of having a new method in
>> FSIndex, which will produce a light-weight FSIndex object which operates
>> like a
>> base FSIndex object, except that it produces these new kinds of iterators.
>> This is as-opposed-to a new iterator() method, because the Iterable
>> interface
>> makes use of the iterator() method...
>>
>> The method to specify that the new iterators for an existing FSIndex would
>> be
>> something like "withSnapshotIterators()".  You would use it like this:
>>
>>    FSIndex  myNormalIndex = myIndexRepository.getIndex("myIndexName");
>>
>>    FSIndex snapshotVersionOfIndex = myNormalIndex.withSnapshotIterators();
>>
>> Some observations:
>>    The withSnapshotIterators could "update" the FSIndex object, or create
>> a new
>> (lightweight) copy of it with the new configuration.
>>       -  Which should it do?  It seems that making a (very light-weight)
>> copy
>> would be safer, so I'm leaning that way
>>
>>    The forms could of course be combined:
>>        e.g.:   for (FeatureStructure fs :
>> indexRepo.getIndex("foo").withSnapshotIterators) ....
>>
>> Another way of writing this is:
>>    with_snapshot_iterators()     There have been studies that this is
>> easier to
>> read, and it seems that way to me...
>>
>> The "with...." part in the name seem good (to me) because it implies you
>> still
>> have an FSIndex; only the iterator part is changed (which is the case).
>>
>> WDYT?
>>
>> -Marshall
>>


Re: name and style for new UIMA iterators

Posted by Burn Lewis <bu...@gmail.com>.
With_underscores may be easier to read but all the other methods use
camelCase ... which admittedly has the lower-case I / uppercase i confusion.

Another alternative is to change the "safeness" of the index. e.g.
myIndex.setSafeIteration(true/false);

~Burn

On Thu, Dec 4, 2014 at 11:13 AM, Marshall Schor <ms...@schor.com> wrote:

> I'm working on providing UIMA will some new iterators that allow arbitrary
> index
> modifications while you're iterating;  they do this by essentially
> "copying" the
> state of the index when the iterator is created, and using that copy in a
> read-only mode to do the iteration, thus allowing the original indices to
> be
> updated while iterating (the iterator won't see those index updates).
>
> This supports use cases such as iterating over some FSs of some type, and
> removing some of them, updating them and adding them back, etc.
>
> I'm thinking various alternatives for specifying this kind of iterator.  To
> preserve the ability of using the Java extended "for" statement:
>
>    for (FeatureStructure fs : myIndex)
>
> where myIndex is of type FSIndex, I'm thinking of having a new method in
> FSIndex, which will produce a light-weight FSIndex object which operates
> like a
> base FSIndex object, except that it produces these new kinds of iterators.
> This is as-opposed-to a new iterator() method, because the Iterable
> interface
> makes use of the iterator() method...
>
> The method to specify that the new iterators for an existing FSIndex would
> be
> something like "withSnapshotIterators()".  You would use it like this:
>
>    FSIndex  myNormalIndex = myIndexRepository.getIndex("myIndexName");
>
>    FSIndex snapshotVersionOfIndex = myNormalIndex.withSnapshotIterators();
>
> Some observations:
>    The withSnapshotIterators could "update" the FSIndex object, or create
> a new
> (lightweight) copy of it with the new configuration.
>       -  Which should it do?  It seems that making a (very light-weight)
> copy
> would be safer, so I'm leaning that way
>
>    The forms could of course be combined:
>        e.g.:   for (FeatureStructure fs :
> indexRepo.getIndex("foo").withSnapshotIterators) ....
>
> Another way of writing this is:
>    with_snapshot_iterators()     There have been studies that this is
> easier to
> read, and it seems that way to me...
>
> The "with...." part in the name seem good (to me) because it implies you
> still
> have an FSIndex; only the iterator part is changed (which is the case).
>
> WDYT?
>
> -Marshall
>