You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@rya.apache.org by jessehatfield <gi...@git.apache.org> on 2017/08/28 22:55:38 UTC

[GitHub] incubator-rya pull request #218: RYA-301 owl:ReflexiveProperty inference

GitHub user jessehatfield opened a pull request:

    https://github.com/apache/incubator-rya/pull/218

    RYA-301 owl:ReflexiveProperty inference

    <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
    
      http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
    ## Description
    1. Added owl:ReflexiveProperty inference: If :hasFamilyMember is reflexive, then `?x :hasFamilyMember ?y` is true for `?x==?y`. Inference engine now loads reflexive properties like it does transitive and symmetric properties, and a visitor expands triples involving reflexive properties to match both when the triple actually exists or when the subject and object are the same.
    
    2. Minor cleanup to wrap up latest inference changes: added/fixed configuration constants to enable/disable those inference visitors that were missing them or using the wrong one; fixed packaging for two test classes.
    ### Tests
    Test rewriting done by ReflexivePropertyVisitor; test that InferenceEngine correctly determines property types; test queries involving reflexive properties.
    
    ### Links
    [Jira](https://issues.apache.org/jira/browse/RYA-301)
    
    ### Checklist
    - [ ] Code Review
    - [ ] Squash Commits
    
    #### People To Reivew
    @meiercaleb @pujav65 @ejwhite922 @isper3at 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jessehatfield/incubator-rya RYA-301-reflexiveproperty-inference

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-rya/pull/218.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #218
    
----
commit 86b5124015de895a451f2385be1f638c2c95f2ed
Author: Jesse Hatfield <je...@parsons.com>
Date:   2017-08-28T22:46:02Z

    RYA-301 owl:ReflexiveProperty inference

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #218: RYA-301 owl:ReflexiveProperty inference

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-rya/pull/218


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #218: RYA-301 owl:ReflexiveProperty inference

Posted by ejwhite922 <gi...@git.apache.org>.
Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/218#discussion_r135875974
  
    --- Diff: common/rya.api/src/main/java/org/apache/rya/api/RdfCloudTripleStoreConfiguration.java ---
    @@ -72,15 +72,21 @@
         public static final String CONF_STATEMENT_METADATA_PROPERTIES = "statement.metadata.properites";
         public static final String CONF_USE_STATEMENT_METADATA = "use.statement.metadata";
         public static final String STATS_PUSH_EMPTY_RDFTYPE_DOWN = "conf.stats.rdftype.down";
    +    public static final String INFER_INCLUDE_ALL_VALUES_FROM = "infer.include.allvaluesfrom";
    +    public static final String INFER_INCLUDE_DOMAIN_RANGE = "infer.include.domainrange";
    +    public static final String INFER_INCLUDE_HAS_SELF = "infer.include.hasself";
    +    public static final String INFER_INCLUDE_HAS_VALUE = "infer.include.hasvalue";
         public static final String INFER_INCLUDE_INTERSECTION_OF = "infer.include.intersectionof";
         public static final String INFER_INCLUDE_INVERSEOF = "infer.include.inverseof";
         public static final String INFER_INCLUDE_ONE_OF = "infer.include.oneof";
    +    public static final String INFER_INCLUDE_PROPERTY_CHAIN = "infer.include.propertychain";
    +    public static final String INFER_INCLUDE_REFLEXIVEPROP = "infer.include.reflexiveprop";
    --- End diff --
    
    Nit. Change ...REFLEXIVEPROP to ...REFLEXIVE_PROP to match the style of the rest of the variable names.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #218: RYA-301 owl:ReflexiveProperty inference

Posted by ejwhite922 <gi...@git.apache.org>.
Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/218#discussion_r135879830
  
    --- Diff: sail/src/main/java/org/apache/rya/rdftriplestore/inference/InferenceEngine.java ---
    @@ -211,33 +212,9 @@ public void refreshGraph() throws InferenceEngineException {
     
                 refreshOneOf();
     
    -            iter = RyaDAOHelper.query(ryaDAO, null, RDF.TYPE, OWL.SYMMETRICPROPERTY, conf);
    -            final Set<URI> symProp = new HashSet<>();
    -            try {
    -                while (iter.hasNext()) {
    -                    final Statement st = iter.next();
    -                    symProp.add((URI) st.getSubject()); //safe to assume it is a URI?
    -                }
    -            } finally {
    -                if (iter != null) {
    -                    iter.close();
    -                }
    -            }
    -            symmetricPropertySet = symProp;
    -
    -            iter = RyaDAOHelper.query(ryaDAO, null, RDF.TYPE, OWL.TRANSITIVEPROPERTY, conf);
    -            final Set<URI> transProp = new HashSet<>();
    -            try {
    -                while (iter.hasNext()) {
    -                    final Statement st = iter.next();
    -                    transProp.add((URI) st.getSubject());
    -                }
    -            } finally {
    -                if (iter != null) {
    -                    iter.close();
    -                }
    -            }
    -            transitivePropertySet = transProp;
    +            symmetricPropertySet = fetchInstances(OWL.SYMMETRICPROPERTY);
    +            transitivePropertySet = fetchInstances(OWL.TRANSITIVEPROPERTY);
    +            reflexivePropertySet = fetchInstances(VF.createURI(OWL.NAMESPACE, "ReflexiveProperty"));
    --- End diff --
    
    Turn the ReflexiveProperty URI into a constant so it doesn't need to be created each the engine is refreshed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya issue #218: RYA-301 owl:ReflexiveProperty inference

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:

    https://github.com/apache/incubator-rya/pull/218
  
    
    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/464/



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya issue #218: RYA-301 owl:ReflexiveProperty inference

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:

    https://github.com/apache/incubator-rya/pull/218
  
    
    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/467/<h2>Failed Tests: <span class='status-failure'>3</span></h2><h3><a name='incubator-rya-master-with-optionals-pull-requests/org.apache.rya:rya.prospector' /><a href='https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/467/org.apache.rya$rya.prospector/testReport'>incubator-rya-master-with-optionals-pull-requests/org.apache.rya:rya.prospector</a>: <span class='status-failure'>3</span></h3><ul><li><a href='https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/467/org.apache.rya$rya.prospector/testReport/org.apache.rya.prospector.mr/ProspectorTest/testCount/'><strong>org.apache.rya.prospector.mr.ProspectorTest.testCount</strong></a></li><li><a href='https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/467/org.apache.rya$rya.prospector/testReport/org.apache.rya.prospector.service/ProspectorServiceEvalStatsDAOTest/testCount
 /'><strong>org.apache.rya.prospector.service.ProspectorServiceEvalStatsDAOTest.testCount</strong></a></li><li><a href='https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/467/org.apache.rya$rya.prospector/testReport/org.apache.rya.prospector.service/ProspectorServiceEvalStatsDAOTest/testNoAuthsCount/'><strong>org.apache.rya.prospector.service.ProspectorServiceEvalStatsDAOTest.testNoAuthsCount</strong></a></li></ul>



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #218: RYA-301 owl:ReflexiveProperty inference

Posted by ejwhite922 <gi...@git.apache.org>.
Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/218#discussion_r135882345
  
    --- Diff: sail/src/main/java/org/apache/rya/rdftriplestore/inference/InferenceEngine.java ---
    @@ -405,6 +382,30 @@ public void refreshGraph() throws InferenceEngineException {
         }
     
         /**
    +     * Query for and collect all instances of a given type. Should only be called for types expected
    +     * to have few members, such as ontology vocabulary terms, as instances will be collected in
    +     * memory.
    +     */
    +    private Set<URI> fetchInstances(final URI type) throws QueryEvaluationException {
    +        final Set<URI> instances = new HashSet<>();
    +        CloseableIteration<Statement, QueryEvaluationException> iter = RyaDAOHelper.query(
    +            ryaDAO, null, RDF.TYPE, type, conf);
    +        try {
    +            while (iter.hasNext()) {
    +                final Statement st = iter.next();
    +                if (st.getSubject() instanceof URI) {
    +                    instances.add((URI) st.getSubject());
    +                }
    +            }
    +        } finally {
    +            if (iter != null) {
    +                iter.close();
    +            }
    +        }
    --- End diff --
    
    This can be reduced to:
    ```
                ryaDaoQueryWrapper.queryAll(null, RDF.TYPE, type, new RDFHandlerBase() {
                    @Override
                    public void handleStatement(final Statement st) throws RDFHandlerException {
                        if (st.getSubject() instanceof URI) {
                            instances.add((URI) st.getSubject());
                        }
                    }
                });
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya issue #218: RYA-301 owl:ReflexiveProperty inference

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:

    https://github.com/apache/incubator-rya/pull/218
  
    
    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/462/



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #218: RYA-301 owl:ReflexiveProperty inference

Posted by ejwhite922 <gi...@git.apache.org>.
Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/218#discussion_r135878109
  
    --- Diff: sail/src/main/java/org/apache/rya/rdftriplestore/inference/ReflexivePropertyVisitor.java ---
    @@ -0,0 +1,73 @@
    +package org.apache.rya.rdftriplestore.inference;
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
    +import org.openrdf.model.URI;
    +import org.openrdf.query.algebra.StatementPattern;
    +import org.openrdf.query.algebra.Var;
    +import org.openrdf.query.algebra.ZeroLengthPath;
    +
    +/**
    + * Expands the query tree to account for any relevant reflexive properties
    + * known to the {@link InferenceEngine}.
    + *
    + * A reflexive property is a property for which any node can be inferred to have
    + * reflexively: If :p is a reflexive property, then <?x :p ?x> is true for all ?x.
    + *
    + * Applies to any statement pattern whose predicate is defined (not a variable)
    + * and is a reflexive property according to the InferenceEngine. If the property
    + * is reflexive, then the statement pattern should match when the subject equals
    + * the object. Therefore, replace the statement pattern with a union of itself
    + * and a ZeroLengthPath between the subject and object. This union is similar to
    + * the ZerOrOnePath property path expression in SPARQL: <?x :p? ?y> matches if
    --- End diff --
    
    typo. ZeroOrOnePath


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---