public class ReasonerUtils extends Object
Utiliy class providing useful functionalities.
| Constructor and Description |
|---|
ReasonerUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areDisjointTypes(SchemaConcept parent,
SchemaConcept child)
determines disjointness of parent-child types, parent defines the bound on the child
|
static <T extends SchemaConcept> |
compatibleRelationTypesWithRoles(Set<T> types,
SchemaConceptConverter<T> schemaConceptConverter)
NB: assumes MATCH semantics - all types and their subs are considered
compute the map of compatible
RelationshipTypes for a given set of Types
(intersection of allowed sets of relation types for each entry type) and compatible role types |
static Set<Role> |
compatibleRoles(Role parentRole,
Type parentType,
Set<Role> entryRoles)
NB: assumes MATCH semantics - all types and their subs are considered
|
static Set<Role> |
compatibleRoles(Type type,
Set<Role> relRoles) |
static IdPredicate |
getIdPredicate(Var typeVariable,
VarPatternAdmin typeVar,
Set<VarPatternAdmin> vars,
ReasonerQuery parent)
looks for an appropriate var property with a specified name among the vars and maps it to an IdPredicate,
covers both the cases when variable is and isn't user defined
|
static IdPredicate |
getUserDefinedIdPredicate(Var typeVariable,
Set<VarPatternAdmin> vars,
ReasonerQuery parent)
looks for an appropriate var property with a specified name among the vars and maps it to an IdPredicate,
covers the case when specified variable name is user defined
|
static Set<ValuePredicate> |
getValuePredicates(Var valueVariable,
VarPatternAdmin valueVar,
Set<VarPatternAdmin> vars,
ReasonerQuery parent)
looks for appropriate var properties with a specified name among the vars and maps them to ValuePredicates,
covers both the case when variable is and isn't user defined
|
static <K,V> com.google.common.collect.Multimap<K,V> |
multimapIntersection(com.google.common.collect.Multimap<K,V> m1,
com.google.common.collect.Multimap<K,V> m2)
calculates map intersection by doing an intersection on key sets and accumulating the keys
|
static <T> Collection<T> |
subtract(Collection<T> a,
Collection<T> b) |
static Set<SchemaConcept> |
supers(SchemaConcept schemaConcept) |
static <T extends SchemaConcept> |
top(Set<T> schemaConcepts) |
static <T extends SchemaConcept> |
topOrMeta(Set<T> schemaConcepts) |
static boolean |
typesCompatible(SchemaConcept parent,
SchemaConcept child) |
static Unifier |
typeUnifier(Set<TypeAtom> childTypes,
Set<TypeAtom> parentTypes,
Unifier childParentUnifier) |
static Set<SchemaConcept> |
upstreamHierarchy(SchemaConcept concept) |
public static IdPredicate getUserDefinedIdPredicate(Var typeVariable, Set<VarPatternAdmin> vars, ReasonerQuery parent)
typeVariable - variable name of interestvars - VarAdmins to look for propertiesparent - reasoner query the mapped predicate should belong to@Nullable public static IdPredicate getIdPredicate(Var typeVariable, VarPatternAdmin typeVar, Set<VarPatternAdmin> vars, ReasonerQuery parent)
typeVariable - variable name of interesttypeVar - VarPatternAdmin to look for in case the variable name is not user definedvars - VarAdmins to look for propertiesparent - reasoner query the mapped predicate should belong topublic static Set<ValuePredicate> getValuePredicates(Var valueVariable, VarPatternAdmin valueVar, Set<VarPatternAdmin> vars, ReasonerQuery parent)
valueVariable - variable name of interestvalueVar - VarPatternAdmin to look for in case the variable name is not user definedvars - VarAdmins to look for propertiesparent - reasoner query the mapped predicate should belong topublic static Set<SchemaConcept> supers(SchemaConcept schemaConcept)
schemaConcept - input typepublic static Set<SchemaConcept> upstreamHierarchy(SchemaConcept concept)
concept - which hierarchy should be consideredSchemaConcepts consisting of the provided SchemaConcept and all its supers including metapublic static <K,V> com.google.common.collect.Multimap<K,V> multimapIntersection(com.google.common.collect.Multimap<K,V> m1,
com.google.common.collect.Multimap<K,V> m2)
K - map key typeV - map value typem1 - first operandm2 - second operandpublic static <T extends SchemaConcept> com.google.common.collect.Multimap<RelationshipType,Role> compatibleRelationTypesWithRoles(Set<T> types, SchemaConceptConverter<T> schemaConceptConverter)
RelationshipTypes for a given set of Types
(intersection of allowed sets of relation types for each entry type) and compatible role typesT - type generictypes - for which the set of compatible RelationshipTypes is to be computedschemaConceptConverter - converter between SchemaConcept and relation type-role entriesRelationshipTypes and their corresponding Rolespublic static Set<Role> compatibleRoles(Role parentRole, Type parentType, Set<Role> entryRoles)
public static <T extends SchemaConcept> Set<T> top(Set<T> schemaConcepts)
schemaConcepts - entry SchemaConcept setSchemaConcepts from within the provided setpublic static <T extends SchemaConcept> Set<T> topOrMeta(Set<T> schemaConcepts)
schemaConcepts - entry SchemaConcept setSchemaConcepts from within the provided set or meta concept if it existspublic static Unifier typeUnifier(Set<TypeAtom> childTypes, Set<TypeAtom> parentTypes, Unifier childParentUnifier)
childTypes - type atoms of child queryparentTypes - type atoms of parent querychildParentUnifier - unifier to unify child with parentpublic static boolean typesCompatible(SchemaConcept parent, SchemaConcept child)
parent - typechild - typepublic static boolean areDisjointTypes(SchemaConcept parent, SchemaConcept child)
parent - SchemaConceptchild - SchemaConceptpublic static <T> Collection<T> subtract(Collection<T> a, Collection<T> b)
T - collection typea - subtraction left operandb - subtraction right operandCopyright © 2018 Grakn Labs Ltd. All rights reserved.