Class RestrictionManagerImpl
java.lang.Object
org.aksw.jena_sparql_api.restriction.RestrictionManagerImpl
- All Implemented Interfaces:
RestrictionManager
This class combines two concepts:
- Construction of expressions
- Binding variables to values (thus constraining the set of possible values for variables)
Furthermore, we can distinguish between bindings inferred from expressions,
such as (?p = rdf:type) -> (?p -> rdf:type)
and bindings stated by the user
A monotone container for assigning constraints to expressions.
A constraint that has been added cannot be removed anymore.
WARNING: While working on an instance having the parent set,
do not modify any of the parents in the chain. Otherwise
results can be unexpected.
Note adding constraints to variables is logically equivalent
to extending the encapsulated filter expression with
[...] AND (constraint). e.g. [?a = foo] AND (?a prefix bar)
Therfore, if a constraint is inconsistent (FALSE), then the
whole expression is inconsistent.
Furthermore, it is possible to state expressions, such as
?a = concat('foo', bar).
In this case, constraints for the variable will be derived
from the expression.
TODO Now that i realize: actually we first derive a description
(startsWith), and depending on the context we derive a constraint.
However, a description is always a constraint (for what it describes and vice versa)
so there is no point in separating the concepts in the class hierarchy,
but on the instance level (so when using these constraints).
TODO Actually we can delay checking of filter expressions
- Author:
- Claus Stadler <cstadler@informatik.uni-leipzig.de>
-
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidcheck(org.apache.jena.sparql.core.Var var) voidcheckClauses(Collection<Clause> clauses) voidcollectRestrictions(Map<org.apache.jena.sparql.core.Var, RestrictionImpl> result) static RestrictionImplstatic RestrictionImplderiveRestriction(org.apache.jena.sparql.expr.E_StrConcat expr) static RestrictionImplderiveRestriction(org.apache.jena.sparql.expr.Expr expr) static RestrictionImplderiveRestrictionConcat(org.apache.jena.sparql.expr.ExprFunction concat) voidderiveRestrictions(Set<Clause> cnf) determineSatisfiability(org.apache.jena.sparql.expr.Expr expr) Test whether the given expression is satisfiable in regard to the given restrictionsstatic BooleanSupported Constraints: Constant, StartsWith1Map<org.apache.jena.sparql.core.Var,org.apache.jena.graph.Node> getClausesForVar(org.apache.jena.sparql.core.Var var) getClausesForVars(Collection<org.apache.jena.sparql.core.Var> vars) Returns all clauses having any of the given variablesgetCnf()voidI use this method for getting constraints for finding view candidatesgetEffectiveDnf(Collection<org.apache.jena.sparql.core.Var> vars) org.apache.jena.sparql.expr.ExprListgetExprs()getOrCreateLocalRestriction(org.apache.jena.sparql.core.Var a) getRestriction(org.apache.jena.sparql.core.Var a) Get the restriction associated with the given variablegetRestriction(org.apache.jena.sparql.expr.Expr expr) Return the restriction associated with as expression.Map<org.apache.jena.sparql.core.Var,RestrictionImpl> Set<org.apache.jena.sparql.core.Var>booleanvoidstateCnf(NestedNormalForm newCnf) voidstateExpr(org.apache.jena.sparql.expr.Expr expr) States a new expression, which is treated as conjuncted with previous expressions.voidstateLiteral(org.apache.jena.sparql.core.Var a, org.apache.jena.sparql.expr.NodeValue b) voidstateNode(org.apache.jena.sparql.core.Var a, org.apache.jena.graph.Node b) voidstateNonEqual(org.apache.jena.sparql.core.Var a, org.apache.jena.sparql.core.Var b) booleanbooleanstateRestriction(org.apache.jena.sparql.core.Var var, RestrictionImpl restriction) voidstateType(org.apache.jena.sparql.core.Var a, RdfTermType type) voidvoidstateUriPrefixes(org.apache.jena.sparql.core.Var a, PrefixSet prefixes) toString()
-
Constructor Details
-
RestrictionManagerImpl
public RestrictionManagerImpl() -
RestrictionManagerImpl
-
RestrictionManagerImpl
-
-
Method Details
-
getCnf
-
getSatisfiability
-
deriveRestriction
-
deriveRestriction
-
deriveRestriction
-
deriveRestrictionConcat
public static RestrictionImpl deriveRestrictionConcat(org.apache.jena.sparql.expr.ExprFunction concat) -
deriveRestrictions
-
stateRestriction
-
getClausesForVar
-
getClausesForVars
Returns all clauses having any of the given variables- Parameters:
vars-- Returns:
-
check
public void check(org.apache.jena.sparql.core.Var var) -
checkClauses
-
check
-
determineSatisfiability
Description copied from interface:RestrictionManagerTest whether the given expression is satisfiable in regard to the given restrictions- Specified by:
determineSatisfiabilityin interfaceRestrictionManager- Parameters:
expr- The expression to test for satisfiability- Returns:
- The assessment of the satisfiability
-
collectRestrictions
-
getRestrictions
-
getRestriction
Description copied from interface:RestrictionManagerReturn the restriction associated with as expression. If the expression is a variable, getRestriction(Var) is invoked. restriction[concat("a", "b")] = prefixset({"ab"})- Specified by:
getRestrictionin interfaceRestrictionManager- Returns:
-
determineSatisfiabilityEquals
Supported Constraints: Constant, StartsWith1- Parameters:
r-c-
-
getRestriction
Description copied from interface:RestrictionManagerGet the restriction associated with the given variable- Specified by:
getRestrictionin interfaceRestrictionManager- Returns:
-
getOrCreateLocalRestriction
- Specified by:
getOrCreateLocalRestrictionin interfaceRestrictionManager
-
stateType
- Specified by:
stateTypein interfaceRestrictionManager
-
stateNode
public void stateNode(org.apache.jena.sparql.core.Var a, org.apache.jena.graph.Node b) - Specified by:
stateNodein interfaceRestrictionManager
-
stateUri
- Specified by:
stateUriin interfaceRestrictionManager
-
stateLiteral
public void stateLiteral(org.apache.jena.sparql.core.Var a, org.apache.jena.sparql.expr.NodeValue b) - Specified by:
stateLiteralin interfaceRestrictionManager
-
stateExpr
public void stateExpr(org.apache.jena.sparql.expr.Expr expr) States a new expression, which is treated as conjuncted with previous expressions. This means that the restrictions are monotone in regard to adding new expressions. Given (?a = b) && (?a = x || ?a = y) Note: We are only interested in 'global' restrictions, we are not dealing with alternate varible assignments here (e.g. ?a = x OR ?a = y)- Parameters:
expr-
-
stateCnf
-
stateNonEqual
public void stateNonEqual(org.apache.jena.sparql.core.Var a, org.apache.jena.sparql.core.Var b) - Specified by:
stateNonEqualin interfaceRestrictionManager
-
getBindings
-
getVariables
-
stateRestriction
-
getEffectiveDnf
-
getExprs
public org.apache.jena.sparql.expr.ExprList getExprs() -
getEffectiveDnf
I use this method for getting constraints for finding view candidates- Parameters:
dnfs-index-dnfIndex-blacklist-depth-parentClause-result-
-
toString
-
stateUriPrefixes
-
isUnsatisfiable
public boolean isUnsatisfiable()
-