Github user meiercaleb commented on a diff in the pull request:
https://github.com/apache/incubator-rya/pull/217#discussion_r135061587
--- Diff:
sail/src/main/java/org/apache/rya/rdftriplestore/inference/InferenceEngine.java
---
@@ -1220,6 +1266,71 @@ public void setSchedule(final boolean schedule) {
}
/**
+ * Given some schema mapping types to (type, property) pairs that
somehow imply the key type,
+ * and given a particular type being queried for, expand the
combinations of types and
+ * properties that can imply the query type by including any pairs
that could imply subtypes of
+ * the query type (using the subclass graph), and by expanding each
property into a set of all
+ * subproperties that imply it (using the subproperty graph). Does not
consider subtypes of
+ * potential triggering types.
+ * @param queryType The type whose possible derivations are needed
+ * @param schemaMap Map of schema information such that each key
represents a type that can
+ * somehow be derived from (other type x property) combinations,
and the value provides
+ * those combinations that can be used for the implication.
+ * @return Combinations of types and properties that can directly or
indirectly imply the query
+ * type according to the schema provided and the
subclass/superproperty graphs. Any
+ * individual type/property combination is sufficient.
+ */
+ private Map<Resource, Set<URI>> getTypePropertyImplyingType(final
Resource queryType, final Map<Resource, Map<Resource, URI>> schemaMap) {
+ final Map<Resource, Set<URI>> implications = new HashMap<>();
+ if (schemaMap != null) {
+ // Check for any subtypes which would in turn imply the type
being queried for
+ final HashSet<Resource> queryTypes = new HashSet<>();
+ queryTypes.add(queryType);
+ if (queryType instanceof URI) {
+ queryTypes.addAll(getSubClasses((URI) queryType));
+ }
+ for (final Resource querySubType : queryTypes) {
+ if (schemaMap.containsKey(querySubType)) {
+ final Map<Resource, URI> otherTypeToProperty =
schemaMap.get(querySubType);
+ for (final Resource otherType :
otherTypeToProperty.keySet()) {
+ if (!implications.containsKey(otherType)) {
+ implications.put(otherType, new HashSet<>());
+ }
+ final URI property =
otherTypeToProperty.get(otherType);
+ implications.get(otherType).add(property);
+ // Also add subproperties that would in turn imply
the property
+
implications.get(otherType).addAll(getSubProperties(property));
+ }
+ }
+ }
+ }
+ return implications;
+ }
+
+ /**
+ * For a given type, return information about any owl:someValuesFrom
restriction that could
+ * imply an individual's membership in that type: When a property
restriction R applies to
+ * property p and states "R owl:someValuesFrom T", then whenever the
object of a triple belongs
+ * to T, and the predicate is p, then the subject of the triple is
implied to have the type R
+ * (it belongs to the class defined by the restriction).
+ * @param restrictionType The type to be inferred, which is the type
of the subject of the
+ * triple, or the type for which all members are stated to have
some value of the
+ * appropriate type. Takes class hierarchy into account, so
possible inferences include
+ * any ways of inferring subtypes of the restriction type, and
object types that trigger
+ * inference include any subtypes of relevant value types. Also
considers property
+ * hierarchy, so properties that trigger inference will include
subproperties of those
+ * referenced by relevant restrictions.
+ * @return A map from object type (the object of the someValuesFrom
condition or the subtype of
+ * such a type) to the set of properties (including any property
referenced by such a
+ * restriction and all of its subproperties) such that for any
individual which belongs to
+ * the object type, any subject which has some value of that type
for that property belongs
+ * to the restriction type.
+ */
+ public Map<Resource, Set<URI>>
getSomeValuesFromByRestrictionType(Resource restrictionType) {
--- End diff --
Null check.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---