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

RYA-295 owl:allValuesFrom inference #201

Conversation

jessehatfield
Copy link
Contributor

Description

Inference applies owl:allValuesFrom semantics for queries including statement patterns of the form "?x rdf:type :DefinedClass".

An owl:allValuesFrom property restriction is a universal class expression: it defines type T1 to be the set of individuals such that, for a given property p and type T2, all values of that property (i.e. all objects of triples where the predicate is p and the subject belongs to T1) have type T2. Therefore, if an individual is known to belong to the universal class expression (T1), then it can be inferred that all of its values for the property belong to the value type (T2). This is similar to rdfs:range except that it only applies when the subject of the triple belongs to the appropriate class expression.

InferenceEngine, at refresh time, stores information about owl:allValuesFrom restrictions (universal class expressions). These definitions can then be accessed by the value type: getAllValuesFromByValueType() returns every (restriction type, property) pair.

AllValuesFromVisitor processes statement patterns of the form "?x rdf:type :T2", and if :T2 is the value type for any owl:allValuesFrom restriction according to the inference engine, it replaces the statement pattern with a union: of 1) that same statement pattern (in case the type is explicitly asserted or can be inferred by some other rule); and 2) a subquery of the form "?y :p ?x . ?y rdf:type :T1" for the appropriate (restriction type, property) pair.

RdfCloudTripleStoreConnection calls the visitor along with the other inference logic. Because the original statement pattern is preserved as one branch of the union, other visitors can still apply if there are other ways to derive the type.

Added a simple example of a query that relies on this inference to MongoRyaDirectExample.

Tests

Unit test to verify that InferenceEngine stores and returns the schema; unit test to verify that AllValuesFromVisitor rewrites queries of the proper form; integration test to verify correct results for sample ontology+instances+query relying on allValuesFrom inference.

Links

Jira

Checklist

  • Code Review
  • Squash Commits

People To Reivew

@ejwhite922
@isper3at
@meiercaleb
@pujav65

@asfgit
Copy link

asfgit commented Aug 8, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/373/

Copy link
Contributor

@ejwhite922 ejwhite922 left a comment

Choose a reason for hiding this comment

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

Looks good.

@jessehatfield jessehatfield force-pushed the RYA-295-allValuesFrom-inference branch from 55eae37 to 316eb76 Compare August 14, 2017 21:34
@jessehatfield
Copy link
Contributor Author

Fixed a typo in a log message and a redundant line in the example; updated with latest changes to master.

@@ -416,6 +418,36 @@ private void refreshHasValueRestrictions(Map<Resource, URI> restrictions) throws
}
}

private void refreshAllValuesFromRestrictions(Map<Resource, URI> restrictions) throws QueryEvaluationException {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to outline the flow of logic here. E.g. refreshes allValuesRestrictions by creating a map of maps from the value class to a map that associates restrictions with properties.

@jessehatfield jessehatfield force-pushed the RYA-295-allValuesFrom-inference branch from 316eb76 to 89747b2 Compare August 18, 2017 16:01
@asfgit
Copy link

asfgit commented Aug 18, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/411/

Build result: FAILURE

[...truncated 222.12 KB...][INFO] ------------------------------------------------------------------------[INFO] Total time: 05:50 min[INFO] Finished at: 2017-08-18T16:08:52+00:00[INFO] Final Memory: 114M/3031M[INFO] ------------------------------------------------------------------------[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project rya.sail: Compilation failure: Compilation failure:[ERROR] /home/jenkins/jenkins-slave/workspace/incubator-rya-master-with-optionals-pull-requests/sail/src/main/java/org/apache/rya/rdftriplestore/inference/InferenceEngine.java:[998,5] illegal start of expression[ERROR] /home/jenkins/jenkins-slave/workspace/incubator-rya-master-with-optionals-pull-requests/sail/src/main/java/org/apache/rya/rdftriplestore/inference/InferenceEngine.java:[998,63] ';' expected[ERROR] /home/jenkins/jenkins-slave/workspace/incubator-rya-master-with-optionals-pull-requests/sail/src/main/java/org/apache/rya/rdftriplestore/inference/InferenceEngine.java:[998,82] ';' expected[ERROR] /home/jenkins/jenkins-slave/workspace/incubator-rya-master-with-optionals-pull-requests/sail/src/main/java/org/apache/rya/rdftriplestore/inference/InferenceEngine.java:[1024,2] reached end of file while parsing[ERROR] -> [Help 1][ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles:[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException[ERROR] [ERROR] After correcting the problems, you can resume the build with the command[ERROR] mvn -rf :rya.sailchannel stoppedSetting status of 89747b2 to FAILURE with url https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/411/ and message: 'FAILURE 'Using context: Jenkins: clean package -Pgeoindexing

@jessehatfield jessehatfield force-pushed the RYA-295-allValuesFrom-inference branch from 89747b2 to 2afd82e Compare August 19, 2017 01:01
@asfgit
Copy link

asfgit commented Aug 19, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/415/

@asfgit asfgit closed this in 2e88f10 Aug 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants