Class RestrictionManagerImpl

java.lang.Object
org.aksw.jena_sparql_api.restriction.RestrictionManagerImpl
All Implemented Interfaces:
RestrictionManager

public class RestrictionManagerImpl extends Object implements 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 Details

    • RestrictionManagerImpl

      public RestrictionManagerImpl()
    • RestrictionManagerImpl

      public RestrictionManagerImpl(RestrictionManagerImpl parent)
    • RestrictionManagerImpl

      public RestrictionManagerImpl(NestedNormalForm cnf)
  • Method Details

    • getCnf

      public NestedNormalForm getCnf()
    • getSatisfiability

      public Boolean getSatisfiability()
    • deriveRestriction

      public static RestrictionImpl deriveRestriction(org.apache.jena.sparql.expr.Expr expr)
    • deriveRestriction

      public static RestrictionImpl deriveRestriction(org.apache.jena.sparql.expr.E_StrConcat expr)
    • deriveRestriction

      public static RestrictionImpl deriveRestriction(E_StrConcatPermissive expr)
    • deriveRestrictionConcat

      public static RestrictionImpl deriveRestrictionConcat(org.apache.jena.sparql.expr.ExprFunction concat)
    • deriveRestrictions

      public void deriveRestrictions(Set<Clause> cnf)
    • stateRestriction

      public boolean stateRestriction(org.apache.jena.sparql.core.Var var, RestrictionImpl restriction)
    • getClausesForVar

      public Set<Clause> getClausesForVar(org.apache.jena.sparql.core.Var var)
    • getClausesForVars

      public Set<Clause> getClausesForVars(Collection<org.apache.jena.sparql.core.Var> vars)
      Returns all clauses having any of the given variables
      Parameters:
      vars -
      Returns:
    • check

      public void check(org.apache.jena.sparql.core.Var var)
    • checkClauses

      public void checkClauses(Collection<Clause> clauses)
    • check

      public void check(Clause clause)
    • determineSatisfiability

      public Boolean determineSatisfiability(org.apache.jena.sparql.expr.Expr expr)
      Description copied from interface: RestrictionManager
      Test whether the given expression is satisfiable in regard to the given restrictions
      Specified by:
      determineSatisfiability in interface RestrictionManager
      Parameters:
      expr - The expression to test for satisfiability
      Returns:
      The assessment of the satisfiability
    • collectRestrictions

      public void collectRestrictions(Map<org.apache.jena.sparql.core.Var,RestrictionImpl> result)
    • getRestrictions

      public Map<org.apache.jena.sparql.core.Var,RestrictionImpl> getRestrictions()
    • getRestriction

      public RestrictionImpl getRestriction(org.apache.jena.sparql.expr.Expr expr)
      Description copied from interface: RestrictionManager
      Return the restriction associated with as expression. If the expression is a variable, getRestriction(Var) is invoked. restriction[concat("a", "b")] = prefixset({"ab"})
      Specified by:
      getRestriction in interface RestrictionManager
      Returns:
    • determineSatisfiabilityEquals

      public static Boolean determineSatisfiabilityEquals(RestrictionImpl a, RestrictionImpl b)
      Supported Constraints: Constant, StartsWith1
      Parameters:
      r -
      c -
    • getRestriction

      public RestrictionImpl getRestriction(org.apache.jena.sparql.core.Var a)
      Description copied from interface: RestrictionManager
      Get the restriction associated with the given variable
      Specified by:
      getRestriction in interface RestrictionManager
      Returns:
    • getOrCreateLocalRestriction

      public RestrictionImpl getOrCreateLocalRestriction(org.apache.jena.sparql.core.Var a)
      Specified by:
      getOrCreateLocalRestriction in interface RestrictionManager
    • stateType

      public void stateType(org.apache.jena.sparql.core.Var a, RdfTermType type)
      Specified by:
      stateType in interface RestrictionManager
    • stateNode

      public void stateNode(org.apache.jena.sparql.core.Var a, org.apache.jena.graph.Node b)
      Specified by:
      stateNode in interface RestrictionManager
    • stateUri

      public void stateUri(org.apache.jena.sparql.core.Var a, String uri)
      Specified by:
      stateUri in interface RestrictionManager
    • stateLiteral

      public void stateLiteral(org.apache.jena.sparql.core.Var a, org.apache.jena.sparql.expr.NodeValue b)
      Specified by:
      stateLiteral in interface RestrictionManager
    • 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

      public void stateCnf(NestedNormalForm newCnf)
    • stateNonEqual

      public void stateNonEqual(org.apache.jena.sparql.core.Var a, org.apache.jena.sparql.core.Var b)
      Specified by:
      stateNonEqual in interface RestrictionManager
    • getBindings

      public Map<org.apache.jena.sparql.core.Var,org.apache.jena.graph.Node> getBindings()
    • getVariables

      public Set<org.apache.jena.sparql.core.Var> getVariables()
    • stateRestriction

      public boolean stateRestriction(RestrictionManagerImpl rm)
    • getEffectiveDnf

      public Set<Clause> getEffectiveDnf(Collection<org.apache.jena.sparql.core.Var> vars)
    • getExprs

      public org.apache.jena.sparql.expr.ExprList getExprs()
    • getEffectiveDnf

      public void getEffectiveDnf(int index, List<Clause> cnfs, Clause parentClause, Set<Clause> result)
      I use this method for getting constraints for finding view candidates
      Parameters:
      dnfs -
      index -
      dnfIndex -
      blacklist -
      depth -
      parentClause -
      result -
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • stateUriPrefixes

      public void stateUriPrefixes(org.apache.jena.sparql.core.Var a, PrefixSet prefixes)
    • isUnsatisfiable

      public boolean isUnsatisfiable()