Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.2.2
-
None
Description
This is related to UIMA-738. if you attempt to call jcas.getType() for a type that's not defined in the type system, the JCas responds by going through the type system and re-creating all of the _Type objects for all known types. For large type systems, this causes some unnecessary work and creates lots of temporary objects that need to be collected.
The situation used to be worse. Under UIMA-738 we fixed problems that caused the JCas to become unstable after this operation. Now at least it doesn't break anything, but there is this performance issue.
To check this, you can run the existing method in JCasTests:
public void testUndefinedType() throws Exception {
//create jcas with no type system
JCas jcas = CasCreationUtils.createCas(new TypeSystemDescription_impl(), null, null).getJCas();
jcas.setDocumentText("This is a test.");
try
catch(CASRuntimeException e) {
}
//check that this does not leave JCAS in an inconsistent state
//(a check for bug UIMA-738)
Iterator iter = jcas.getAnnotationIndex().iterator();
assertTrue(iter.hasNext());
Annotation annot = (Annotation)iter.next();
assertEquals("This is a test.", annot.getCoveredText());
}
The call to jcas.getType(Sentence.type) will cause all known _Type objects to be instantiated (in this case, the builtins). This can be seen from stepping into this method in the debugger, or from putting a breakpoint in the TOP_Type constructor.