Closed syphax-bouazzouni closed 7 months ago
In the section, I will run the same query in the different code bases and give the generated SPARQL query
The query will be the following
University.where.include(:name, programs: [:name]).all
# Get the universities including their name and programs (inverse of university property)
SELECT DISTINCT ?id ?name ?programs
FROM <http://goo.org/default/University>
FROM <http://goo.org/default/Program>
WHERE {
?id a <http://goo.org/default/University> .
OPTIONAL { ?id <http://goo.org/default/name> ?name . }
OPTIONAL { ?programs <http://goo.org/default/university> ?id . }
}
# Get the 9 programs names
SELECT DISTINCT ?id ?name
FROM <http://goo.org/default/Program>
WHERE {
?id a <http://goo.org/default/Program> .
OPTIONAL { ?id <http://goo.org/default/name> ?name . }
FILTER(?id = <http://example.org/program/UPM/CompSci> || ?id = <http://example.org/program/UPM/BioInformatics> || ?id = <http://example.org/program/UPM/Medicine> || ?id = <http://example.org/program/Stanford/Medicine> || ?id = <http://example.org/program/Stanford/BioInformatics> || ?id = <http://example.org/program/Stanford/CompSci> || ?id = <http://example.org/program/Southampton/CompSci> || ?id = <http://example.org/program/Southampton/Medicine> || ?id = <http://example.org/program/Southampton/BioInformatics>)
}
Notes:
# Get the universities including their name and programs (inverse of university property)
SELECT DISTINCT ?id ?attributeProperty ?attributeObject
FROM <http://goo.org/default/University>
FROM <http://goo.org/default/Program>
WHERE {
?id a <http://goo.org/default/University> .
OPTIONAL {
{ ?id <http://goo.org/default/name> ?attributeObject . BIND( "name" as ?attributeProperty) }
UNION
{ ?attributeObject <http://goo.org/default/university> ?id . BIND( "programs" as ?attributeProperty) }
}
}
# Get the 9 programs names
SELECT DISTINCT ?id ?attributeProperty ?attributeObject
FROM <http://goo.org/default/Program>
WHERE {
?id a <http://goo.org/default/Program> .
OPTIONAL {
{ ?id <http://goo.org/default/name> ?attributeObject . BIND( "name" as ?attributeProperty) }
}
FILTER(?id = <http://example.org/program/UPM/CompSci> || ?id = <http://example.org/program/UPM/BioInformatics> || ?id = <http://example.org/program/UPM/Medicine> || ?id = <http://example.org/program/Stanford/Medicine> || ?id = <http://example.org/program/Stanford/BioInformatics> || ?id = <http://example.org/program/Stanford/CompSci> || ?id = <http://example.org/program/Southampton/CompSci> || ?id = <http://example.org/program/Southampton/Medicine> || ?id = <http://example.org/program/Southampton/BioInformatics>)
}
Notes
SELECT DISTINCT ?id ?attributeProperty ?attributeObject
, making it more performant for large elements with a lot of metadata (submission in our case)# Get the universities including their name and programs (inverse of university property)
SELECT DISTINCT ?id ?attributeProperty ?attributeObject
FROM <http://goo.org/default/University>
FROM <http://goo.org/default/Program>
WHERE {
?id a <http://goo.org/default/University> .
OPTIONAL {
{ ?id ?attributeProperty ?attributeObject . FILTER(?attributeProperty = <http://goo.org/default/name>) }
UNION
{ ?attributeObject ?attributeProperty ?id . FILTER(?attributeProperty = <http://goo.org/default/university>) }
}
}
# Get the 9 programs names
SELECT DISTINCT ?id ?attributeProperty ?attributeObject
FROM <http://goo.org/default/Program>
WHERE {
?id a <http://goo.org/default/Program> .
OPTIONAL {
{ ?id ?attributeProperty ?attributeObject . FILTER(?attributeProperty = <http://goo.org/default/name>) }
}
FILTER(?id = <http://example.org/program/Stanford/BioInformatics> || ?id = <http://example.org/program/Stanford/CompSci> || ?id = <http://example.org/program/Stanford/Medicine> || ?id = <http://example.org/program/Southampton/BioInformatics> || ?id = <http://example.org/program/Southampton/CompSci> || ?id = <http://example.org/program/Southampton/Medicine> || ?id = <http://example.org/program/UPM/BioInformatics> || ?id = <http://example.org/program/UPM/CompSci> || ?id = <http://example.org/program/UPM/Medicine>) }
Notes
Ouahh!
Attention: 29 lines
in your changes are missing coverage. Please review.
Comparison is base (
6187c20
) 85.91% compared to head (09c944f
) 85.86%.
Files | Patch % | Lines |
---|---|---|
lib/goo/sparql/processor.rb | 74.39% | 21 Missing :warning: |
lib/goo.rb | 75.00% | 3 Missing :warning: |
lib/goo/base/resource.rb | 83.33% | 2 Missing :warning: |
lib/goo/sparql/solutions_mapper.rb | 95.00% | 2 Missing :warning: |
lib/goo/sparql/client.rb | 92.85% | 1 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Prerequisites
Context
This PR makes the ths following triple stores:
4store
(fs),GraphDb
(gb),Virtuoso
(vo), andAllegroGraph
(ag), work with Goo and add their test workflows.The challenge was that the same query was not parsed from one triple store to another. i.e. the same SPARQL query returns different things. form store to another.
So
GraphDb
works the same as4store
, and is integrated easily into the current code and the way we generate our queries (see an example of a generated query in the section "Generated Queries examples ").Virtuoso
andAllegroGraph
support a better way of handling queries, so we updated our code to write better and simpler queries (see an example of a generated query in the section "Generated Queries examples ").Benchmarks
The table below shows the time that it takes to run all the tests in each of the triple-store, with different slice configurations (slices, is a configuration variable to define how we slice our fetched data, e.g. if we query 100 elements and the slice is 20 we will do 5 requests fetching 20 elements each)
The benchmarks up use our version code not the NCBO one, and we use a different approach to building queries since https://github.com/ncbo/goo/pull/124, so below the benchmark using the NCBO code for 4store and AllegroGraph
So to summarize here is the final board
Generated Queries examples
See https://github.com/ontoportal-lirmm/goo/pull/48#issuecomment-1763725927
Changes