uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Baessler <...@michael-baessler.de>
Subject Re: capabilityLangugaeFlow - computeResultSpec
Date Mon, 07 Jan 2008 11:56:12 GMT
Adam Lally wrote:
> On Dec 18, 2007 8:55 AM, Michael Baessler <mba@michael-baessler.de> wrote:
>   
>> Hi,
>> I got the request on my table that the computation of the result spec
>> for the capabilityLanguageFlow takes to much time.
>> I looked at the code and found something interesting... maybe I'm wrong,
>> I'm not sure.
>>
>> When looking at the ASB_impl.java at processUntilNextOutputCas() I found
>> the following:
>>
>>                //check if we have to set result spec, to support
>> capability language flow
>>                 if (nextStep instanceof SimpleStepWithResultSpec) {
>>                   ResultSpecification rs =
>> ((SimpleStepWithResultSpec)nextStep).getResultSpecification();
>>                   if (rs != null) {
>>                     nextAe.setResultSpecification(rs);
>>                   }
>>                 }
>>                 // invoke next AE in flow
>>                 CasIterator casIter = null;
>>                 CAS outputCas = null; //used if the AE we call outputs a
>> new CAS
>>                 try {
>>                   casIter = nextAe.processAndOutputNewCASes(cas);
>>
>> When a capabilityLanguageFlow is used, the ResultSpec for the flow
>> engines are precomputed if possible. The code above takes this
>> precomputed ResultSpec from the flow node and set it for the current AE.
>>
>> When I go deeper to
>>
>>      casIter = nextAe.processAndOutputNewCASes(cas);
>>
>> I found in the PrimitiveAnalysisEngine_impl.java class in the
>> callAnalysisComponentProcess() method the following:
>>
>>         if (mResultSpecChanged || mLastTypeSystem != view.getTypeSystem()) {
>>           mLastTypeSystem = view.getTypeSystem();
>>           mCurrentResultSpecification.compile(mLastTypeSystem);
>>           // the actual ResultSpec we send to the component is formed by
>>           // looking at this primitive AE's declared output types and
>> eliminiating
>>           // any that are not in mCurrentResultSpecification.
>>           ResultSpecification analysisComponentResultSpec =
>> computeAnalysisComponentResultSpec(
>>                   mCurrentResultSpecification,
>> getAnalysisEngineMetaData().getCapabilities());
>>           // compile result spec - necessary to get type subsumption to
>> work properly
>>           analysisComponentResultSpec.compile(mLastTypeSystem);
>>
>> mAnalysisComponent.setResultSpecification(analysisComponentResultSpec);
>>           mResultSpecChanged = false;
>>         }
>>
>> any time when the ResultSpec changed, the ResultSpec is recomputed. But
>> the ResultSpec is changed any time when setResultSpecification() is called.
>> So what does this mean. The first code fragment in the email shows how
>> to get the ResultSpec from the flow controller and set it on the AE.
>> - So the result spec changed - The second code fragment shows what is
>> executed if the ResultSpec has been changed and how it is recomputed.
>> This means that the ResultSpec is recomputed each time process is
>> called. I don't think this is necessary.
>>
>>     
>
> That seems like a good analysis of the situation.  I think what we
> need is to detect when the ResultSpecification has actually changed
> and when it hasn't.  That might be tricky to do right.  If we just
> check if the new ResultSpecification is == to the existing
> ResultSpecification, that wouldn't work if the ResultSpecification had
> been modified (it would be == but the contents wouldn't be the same).
> Perhaps we could add a dirty flag to the ResultSpecification to catch
> this.
I tried to figure out how the ResultSpecification handling in uima-core 
works with all side effects to check how it can be done
to detect when a ResultSpec has changed. Unfortunately I was not able 
to, there are to much open questions where I don't know
exactly if it is right in any case ... :-(

Adam can you please look at this issue?

Thanks Michael

Mime
View raw message