Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade the built-in Fuseki to version 2.4.0 #268

Merged
merged 2 commits into from Oct 3, 2016
Merged

Conversation

benjamingeer
Copy link

@benjamingeer benjamingeer commented Sep 21, 2016

This upgrades the built-in Fuseki server to version 2.4.0.

I found that three of our SPARQL queries were too slow on Fuseki unless I replaced MINUS with FILTER NOT EXISTS. This issue suggests that previous versions of Fuseki were able to optimise MINUS better than more recent versions, and that FILTER NOT EXISTS can more efficiently replace MINUS in some cases. However, FILTER NOT EXISTS didn't produce the same results in these queries on GraphDB. This is probably related to this issue, which seems to suggest that these two triplestores don't interpret SPARQL scoping rules in quite the same way. As a workaround, I added some if statements to the SPARQL templates in these cases, to use MINUS on GraphDB and FILTER NOT EXISTS on Fuseki. I think this is OK for now. We can revisit it later when we have more time.

I also got a NullPointerException from Fuseki when running one of the search responder tests. It seems to be caused by this bug. The advice there is to add a workaround to the definition of :tdb_dataset_readwrite in the repository configuration:

                        # Fuseki 2.4.0 only - remove for later versions.
                        ja:context [ ja:cxtName "arq:optFilterPlacementBGP" ;
                                     ja:cxtValue "true" ] .

With these workarounds, the tests pass, and performance looks good.

Closes #29.

@benjamingeer benjamingeer added the enhancement improve existing code or new feature label Sep 21, 2016
@benjamingeer benjamingeer added this to the Beta Release milestone Sep 21, 2016
@tobiasschweizer
Copy link
Contributor

tobiasschweizer commented Sep 29, 2016

I am pretty sure you already know this information. Nevertheless I bring it up here: https://www.w3.org/TR/sparql11-query/#neg-example-1

Could hat explain the different behaviour?

If I do these queries in Fuseki, I get either all the resources or none of them.

This returns all the resources:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX knora-base: <http://www.knora.org/ontology/knora-base#>

SELECT * WHERE {

  ?resClass rdfs:subClassOf+ knora-base:Resource .
  ?resource a ?resClass .

  MINUS {
    ?s ?p ?o .
  }

}

This returns no results:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX knora-base: <http://www.knora.org/ontology/knora-base#>

SELECT * WHERE {

  ?resClass rdfs:subClassOf+ knora-base:Resource .
  ?resource a ?resClass .

  FILTER NOT EXISTS {
    ?s ?p ?o .
  }

}

But if you share a variable in MINUS, you get no results as well:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX knora-base: <http://www.knora.org/ontology/knora-base#>

SELECT * WHERE {

  ?resClass rdfs:subClassOf+ knora-base:Resource .
  ?resource a ?resClass .

  MINUS {
    ?resource ?p ?o .
  }

}

So MINUS seems to try to remove matching statements from the results (according to the statements matched so far), but only if you share variables that you use it the statements above. Otherwise the MINUS takes no effect at all, whereas FILTER NOT EXISTS does not seem to care about the context.

If I run the queries above in graphdb, I get the same results but they it takes a long time. So there clearly seems to be a different behaviour which justifies the if in the query templates. If I understand correctly, the queries stay the same for graphdb.

@benjamingeer
Copy link
Author

The best explanation that I was able to get is here, but I don't understand it:

https://issues.apache.org/jira/browse/JENA-1130

I think that at some point we should ask Ontotext about this.

@@ -50,7 +50,7 @@ WHERE {
{
@* Query statements about the resource's file values. *@

?prop rdfs:subPropertyOf* knora-base:hasFileValue .
?prop rdfs:subPropertyOf+ knora-base:hasFileValue .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implies that knora-base:hasFileValue is never used directly, but only by means of subproperties. Correct?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

@benjamingeer
Copy link
Author

Can I merge this now?

@benjamingeer benjamingeer merged commit adc068d into develop Oct 3, 2016
@benjamingeer benjamingeer deleted the wip/fuseki-2-4-0 branch October 3, 2016 14:45
SepidehAlassi added a commit that referenced this pull request Oct 31, 2016
…ip/beol

* 'develop' of https://github.com/dhlab-basel/Knora:
  Update README.md
  test (webapi): add E2E testing (#244)
  BEOL and bibliography ontologies (#283)
  refactor (webapi): migrate spray to akka http (#273)
  fix (sipi error message): display the error message returned by SIPI (#287)
  Add support for editing labels and value comments (#261)
  docs: Convert Knora base ontology doc to RST. (#289)
  relative paths (#288)
  removing relative paths to icons in css file: it doesn't survive an front apache proxy like: (#191)
  adding css and fonts used in the js/jquery.editvalue.js (#180)
  docs: Add remark about pyvenv for anaconda users on mac and linux (#264)
  add internal link to doc/readme (#278)
  docs (extended search): add missing explanations for LIKE and !LIKE (#279)
  Upgrade the built-in Fuseki to version 2.4.0 (#268)

# Conflicts:
#	knora-ontologies/knora-base.ttl
#	webapi/src/test/scala/org/knora/webapi/responders/v1/OntologyResponderV1Spec.scala
@benjamingeer benjamingeer mentioned this pull request Jul 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improve existing code or new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants