NCIEVS / nci-protege5

evs umbrella project for protege 5-based editing software
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

Prototype tree widget to assess alternative architecture #584

Open bdionne opened 11 months ago

bdionne commented 11 months ago

In order to achieve the next level of scalability for the NCIThesaurus, we need to get away from having the entire ontology in memory. This will require using a database and retrieving resources as needed by the user interacting with the GUI.

One of the more intensive components is the navigation pane, which presents the classes of the ontology in a tree widget. We'd like to assess if we can retrieve these classes dynamically as the user scrolls and/or opens and closes nodes.

To support this task we need:

The goal is a simple app that can be used to measure the roundtrip performance. We'll use the to test various server configurations (on-premises versus cloud)

fragosog commented 11 months ago
# can inject IRI or prefixed IRI following the "values" keyward

# count of subclasses, result is a plain literal

prefix ncit: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#> 
select (str(count(?subclass)) as ?count)
from <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl>
where {
  values ?superclass { ncit:C16612 }
  ?subclass (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first) ) ?superclass
}

# count of subclasses, result is the typed literal xsd:string

prefix ncit: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#> 
select (count(?subclass) as ?count)
from <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl>
where {
  values ?superclass { ncit:C16612 }
  ?subclass (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first) ) ?superclass
}

# return subclasses of a class and flag the subclasses that have children
# example with IRI . . .

select distinct ?subclass ?label str(if(bound(?exists), 1, 0) as ?hasChildren)
from <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl>
where {
  values ?superclass { <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C12913> }
  ?subclass (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first) ) ?superclass ;
      rdfs:label ?label .
  optional { ?exists (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first) ) ?subclass . }    
} order by ?label

# or prefixed IRI

prefix ncit: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#> 
select distinct ?subclass ?label str(if(bound(?exists), 1, 0) as ?hasChildren)
from <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl>
where {
  values ?superclass { ncit:C12913 }
  ?subclass (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first) ) ?superclass ;
      rdfs:label ?label .
  optional { ?exists (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first) ) ?subclass . }    
} order by ?label

# for a simple "does a class have children", example with IRI ...

ask {
  values ?super { <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C16612> }
  graph <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl> {
     ?subclass (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first) )  ?super
   }
}

# or prefixed IRI ...

prefix ncit: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#>
ASK {
  values ?super { ncit:C16612 }
  GRAPH <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl> {
     ?subclass (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first) )  ?super .
  }
}
bdionne commented 9 months ago

I cobbled together a simple JTree example that uses RDF4J libs to drive a navigation pane where the queries to retrieve the child nodes occur on demand. Below is also a screenshot that show the time in milliseconds that each took.

Note that regardless of how many or how few child nodes are there, the very first query takes an order of magnitude longer. Not sure what that is, perhaps virtuoso has to wake up a bit.

Screenshot 2024-02-07 at 5 26 34 PM Screenshot 2024-02-07 at 5 52 15 PM