Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-1026

listIndividuals (and listClasses) performance issue

    XMLWordPrintableJSON

Details

    • Question
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • Jena 3.0.0
    • None
    • Ontology API
    • None
    • Verified on Jena 3.0.1-SNAPSHOT (2015-09-13) w/ Ubuntu 14.04/x64, 4 cores i7-3520M, 16G ram, SSD disk, Open JDK 1.8.0_45-internal

    Description

      As reported by Maria Clementina Latanzi on dev@jena 2015-09-12:

      I'm working with Jena. I have an ontology with no more than 50 individuals,
      and I use Jena to
      get individuals from Ontology by calling listIndividual (
      com.hp.hpl.jena.ontology.OntModel.listIndividuals). When I call this
      method, it's taking a lot of time up to 20 seconds. When debugging, it
      takes more than 1 minute to return. Other methods like *listClass *return
      instantly.

      package testOnto;
      
      import java.io.InputStream;
      import java.util.ArrayList;
      import java.util.Iterator;
      import com.hp.hpl.jena.ontology.Individual;
      import com.hp.hpl.jena.ontology.OntClass;
      import com.hp.hpl.jena.ontology.OntModel;
      import com.hp.hpl.jena.rdf.model.ModelFactory;
      import com.hp.hpl.jena.rdf.model.Resource;
      import com.hp.hpl.jena.rdf.model.Property;
      import com.hp.hpl.jena.rdf.model.StmtIterator;
      import com.hp.hpl.jena.rdf.model.impl.StatementImpl;
      import com.hp.hpl.jena.shared.JenaException;
      import com.hp.hpl.jena.util.FileManager;
      import com.hp.hpl.jena.util.iterator.ExtendedIterator;
      
      public class onto {
          static String Ontofile = "C:/Users/Sig/Clemen/OntologiasArchivos/OntologiaIngesta.owl";
      
          public static void main(String[] args) {
              //crea ontologia
      
              OntModel m = ModelFactory.createOntologyModel();
              try {
                  InputStream in = FileManager.get().open("C:/Users/Sig/Clemen/OntologiasArchivosOntologiaDeAlimentos.owl");
                  if (in ==null) {
                      System.out.println("ERROR abriendo archivo" + Ontofile);
                      return;
                  }
                  else {  m.read(in, "RDF/XML");
                      System.out.println("archivo" + Ontofile + "leido exitosamente" );
                  }
              } catch (JenaException je) {
                  System.out.println("ERROR leyendo archivo" + je.getMessage());
                  je.printStackTrace();
                  System.exit(0);
              }
      
              long startMilC = System.currentTimeMillis();
              System.out.println("Start list classes: " + startMilC);
              ExtendedIterator classes = m.listClasses();
              long endMilC = System.currentTimeMillis();
              System.out.println("Duration ListIndividuals: " + (endMilC -startMilC));
              long startMil = System.currentTimeMillis();
      
              System.out.println("Start ListIndividuals: " + startMil);
              ExtendedIterator individuos = m.listIndividuals();
              long endMil = System.currentTimeMillis();
              System.out.println("Duration ListIndividuals: " + (endMil - startMil));
      
          }
      }
      

      See attached ontology and test case.

      Verified against current 3.0.1-SNAPSHOT.

      Attachments

        1. lpb-trace-of-not-much-food.txt
          78 kB
          Stian Soiland-Reyes
        2. not-much-food.ttl
          1 kB
          Stian Soiland-Reyes
        3. onto.java
          2 kB
          Stian Soiland-Reyes
        4. OntologiaDeAlimentos.owl
          90 kB
          Stian Soiland-Reyes

        Activity

          People

            Unassigned Unassigned
            stain Stian Soiland-Reyes
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: