Uploaded image for project: 'UIMA'
  1. UIMA
  2. UIMA-1111

Calling jcas.getType for a type that is not defined in the descriptor causes a lot of object allocation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.2
    • 2.3
    • Core Java Framework
    • 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

      { //this should throw an exception jcas.getType(Sentence.type); fail(); }

      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.

      Attachments

        Activity

          People

            schor Marshall Schor
            alally Adam P. Lally
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: