You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by al...@apache.org on 2007/05/01 15:56:41 UTC
svn commit: r534093 -
/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java
Author: alally
Date: Tue May 1 06:56:40 2007
New Revision: 534093
URL: http://svn.apache.org/viewvc?view=rev&rev=534093
Log:
In CollectionReaderAdapter, subsequent calls to process() after the first one will
now call reconfigure().
UIMA-388: https://issues.apache.org/jira/browse/UIMA-388
Modified:
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java
Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java?view=diff&rev=534093&r1=534092&r2=534093
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java Tue May 1 06:56:40 2007
@@ -51,6 +51,8 @@
private UimaContext mUimaContext;
private boolean mSofaAware;
+
+ private boolean mProcessCalled;
/**
* Create a new annotator adapter.
@@ -64,6 +66,7 @@
AnalysisEngineMetaData aMetaData) {
mCollectionReader = aCollectionReader;
mSofaAware = aMetaData.isSofaAware();
+ mProcessCalled = false;
}
/*
@@ -114,7 +117,21 @@
* @see org.apache.uima.annotator.Annotator#process(org.apache.uima.core.AbstractCas)
*/
public void process(AbstractCas aCAS) throws AnalysisEngineProcessException {
- // does nothing - CollectionReaders ignore their input CAS
+ // Does nothing on the first call to process - CollectionReaders ignore their input CAS.
+ // On a subsequent call to process, we want to reset the CollectionReader, which we
+ // try to do by calling its reconfigure method.
+ if (mProcessCalled) {
+ try {
+ reconfigure();
+ } catch (ResourceInitializationException e) {
+ throw new AnalysisEngineProcessException(e);
+ } catch (ResourceConfigurationException e) {
+ throw new AnalysisEngineProcessException(e);
+ }
+ }
+ else {
+ mProcessCalled = true;
+ }
}
/*
Re: svn commit: r534093 - /incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java
Posted by Marshall Schor <ms...@schor.com>.
Thanks for the background.
Reconfigure was originally (I think) something the application could do
if it changed the
configuration parameters, to tell the "components" to re-read the
parameters and
"reconfigure" itself. If true, this could (conceptually) even be done
in the middle of
a run (say you process the first 100 docs with one set of parameters, then
"reconfigured" and processed the next 100 with another set).
This change is specific to the "Collection Reader Adapter" - a
component that lets collection readers be used as CAS Multipliers. If I
follow the sequence,
we envision a processCas call to the CAS Multiplier, followed by it
calling the collection reader,
and having that return CASes until it's "done". At that point the
initial CAS sent to the CAS Multiplier would
be returned. The next call to the CAS Multiplier could (possibly)
already find the CollectionReader
in the "reset" state - because it had already finished processing all of
its documents: if a collection reader was
designed to be called a second time, it could arrange things to not need any
special reconfigure call. But if a collection was not designed to be
called a second time, it's possible
that a reconfigure call would reset it (especially if the default
implementation of destroy() followed by
initialize() happened).
So - I guess this makes sense to do in this case. I think I would
document this not as the
"framework" calling reconfigure, but rather as a special case of the
Collection Reader Adapter doing it.
-Marshall
Adam Lally wrote:
> On 5/1/07, Marshall Schor <ms...@schor.com> wrote:
>> Not sure about this; the main documentation, in the section 1.5.1 in
>> tutorials / user guides on the "contract" says
>>
>> reconfigure
>>
>> This method is never called by the framework, unless
>> an application calls it on the Engine object – in which
>> case it the framework propagates it to all
>> annotators contained in the Engine.
>>
>> Its purpose is to signal that the configuration
>> parameters have changed. A default implementation
>> of this calls destroy, followed by initialize. This
>> is the only case where initialize would be called
>> more than once. Users should implement whatever
>> logic is needed to return the annotator to an initialized
>> state, including re-reading the configuration parameter
>> data.
>>
>> So this change sounds like a change in the contract for reconfigure?
>>
>
> Technically, that section of the document is only about the contract
> for Annotators, not Collection Readers. We're a lot more vague about
> the contract for Collection Readers. :)
>
> Basically I want some way to tell a Collection Reader to "reset" back
> to the beginning of the collection. I agree if we use reconfigure()
> to do that then the right thing to do is to we should say so in the
> documentation for the Collection Reader interface.
>
> Also I could go along with using destroy() followed by initialize() as
> the trigger for this, if you think that is better than reconfigure().
>
> The CollectionReaderAdapter allows a CollectionReader to be used as a
> CAS Multiplier. This is useful because we have said that
> CollectionReader is just a specialization of CAS Multiplier that
> ignores its input CAS. However since CAS Multipliers can receive
> multiple input CASes we have to figure out what to do on the second
> input CAS. I think the logical thing to do is to restart from the
> beginning of the collection, so I'm looking for some way to do that.
>
> -Adam
>
>
Re: svn commit: r534093 - /incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java
Posted by Adam Lally <al...@alum.rpi.edu>.
On 5/1/07, Marshall Schor <ms...@schor.com> wrote:
> Not sure about this; the main documentation, in the section 1.5.1 in
> tutorials / user guides on the "contract" says
>
> reconfigure
>
> This method is never called by the framework, unless
> an application calls it on the Engine object – in which
> case it the framework propagates it to all
> annotators contained in the Engine.
>
> Its purpose is to signal that the configuration
> parameters have changed. A default implementation
> of this calls destroy, followed by initialize. This
> is the only case where initialize would be called
> more than once. Users should implement whatever
> logic is needed to return the annotator to an initialized
> state, including re-reading the configuration parameter
> data.
>
> So this change sounds like a change in the contract for reconfigure?
>
Technically, that section of the document is only about the contract
for Annotators, not Collection Readers. We're a lot more vague about
the contract for Collection Readers. :)
Basically I want some way to tell a Collection Reader to "reset" back
to the beginning of the collection. I agree if we use reconfigure()
to do that then the right thing to do is to we should say so in the
documentation for the Collection Reader interface.
Also I could go along with using destroy() followed by initialize() as
the trigger for this, if you think that is better than reconfigure().
The CollectionReaderAdapter allows a CollectionReader to be used as a
CAS Multiplier. This is useful because we have said that
CollectionReader is just a specialization of CAS Multiplier that
ignores its input CAS. However since CAS Multipliers can receive
multiple input CASes we have to figure out what to do on the second
input CAS. I think the logical thing to do is to restart from the
beginning of the collection, so I'm looking for some way to do that.
-Adam
Re: svn commit: r534093 - /incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java
Posted by Marshall Schor <ms...@schor.com>.
Not sure about this; the main documentation, in the section 1.5.1 in
tutorials / user guides on the "contract" says
reconfigure
This method is never called by the framework, unless
an application calls it on the Engine object – in which
case it the framework propagates it to all
annotators contained in the Engine.
Its purpose is to signal that the configuration
parameters have changed. A default implementation
of this calls destroy, followed by initialize. This
is the only case where initialize would be called
more than once. Users should implement whatever
logic is needed to return the annotator to an initialized
state, including re-reading the configuration parameter
data.
So this change sounds like a change in the contract for reconfigure?
-Marshall
alally@apache.org wrote:
> Author: alally
> Date: Tue May 1 06:56:40 2007
> New Revision: 534093
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=534093
> Log:
> In CollectionReaderAdapter, subsequent calls to process() after the first one will
> now call reconfigure().
> UIMA-388: https://issues.apache.org/jira/browse/UIMA-388
>
> Modified:
> incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java
>
> Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java
> URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java?view=diff&rev=534093&r1=534092&r2=534093
> ==============================================================================
> --- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java (original)
> +++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/compatibility/CollectionReaderAdapter.java Tue May 1 06:56:40 2007
> @@ -51,6 +51,8 @@
> private UimaContext mUimaContext;
>
> private boolean mSofaAware;
> +
> + private boolean mProcessCalled;
>
> /**
> * Create a new annotator adapter.
> @@ -64,6 +66,7 @@
> AnalysisEngineMetaData aMetaData) {
> mCollectionReader = aCollectionReader;
> mSofaAware = aMetaData.isSofaAware();
> + mProcessCalled = false;
> }
>
> /*
> @@ -114,7 +117,21 @@
> * @see org.apache.uima.annotator.Annotator#process(org.apache.uima.core.AbstractCas)
> */
> public void process(AbstractCas aCAS) throws AnalysisEngineProcessException {
> - // does nothing - CollectionReaders ignore their input CAS
> + // Does nothing on the first call to process - CollectionReaders ignore their input CAS.
> + // On a subsequent call to process, we want to reset the CollectionReader, which we
> + // try to do by calling its reconfigure method.
> + if (mProcessCalled) {
> + try {
> + reconfigure();
> + } catch (ResourceInitializationException e) {
> + throw new AnalysisEngineProcessException(e);
> + } catch (ResourceConfigurationException e) {
> + throw new AnalysisEngineProcessException(e);
> + }
> + }
> + else {
> + mProcessCalled = true;
> + }
> }
>
> /*
>
>
>
>
>