Class SparqlViewSystem

java.lang.Object
org.aksw.sparqlify.sparqlview.SparqlViewSystem

public class SparqlViewSystem extends Object
  • Constructor Details

    • SparqlViewSystem

      public SparqlViewSystem()
  • Method Details

    • rewrite

      public static org.apache.jena.query.Query rewrite(org.apache.jena.query.Query query, SparqlViewSystem system, Dialect dialect)
    • addView

      public void addView(SparqlView view)
    • deriveConstraint

      public static Constraint deriveConstraint(org.apache.jena.sparql.expr.Expr expr)
    • deriveConstraint

      public static StartsWithConstraint deriveConstraint(org.apache.jena.sparql.expr.E_StrConcat expr)
    • deriveConstraint

      public static StartsWithConstraint deriveConstraint(E_StrConcatPermissive expr)
    • deriveConstraintConcat

      public static StartsWithConstraint deriveConstraintConcat(org.apache.jena.sparql.expr.ExprFunction concat)
    • deriveTypeConstraints

      public Map<org.apache.jena.sparql.core.Var,RdfTermType> deriveTypeConstraints(SparqlView view)
    • deriveRestrictions

      public void deriveRestrictions(SparqlView view)
      Derive prefix constraints for variables based on variable definitions: concat('constant', var, rest) -> prefix = 'constant' TODO: Actually we should not add these constraints to the view, but just return them
    • getType

      public static RdfTermType getType(org.apache.jena.graph.Node node, RestrictionManagerImpl restrictions)
    • getApplicableViews

      public org.apache.jena.sparql.algebra.Op getApplicableViews(org.apache.jena.query.Query query)
    • deriveIsPrefixOfConstraint

      public static VariableConstraint deriveIsPrefixOfConstraint(org.apache.jena.sparql.expr.Expr a, org.apache.jena.sparql.expr.Expr b)
      If a variable equals a (uri or string) constant, it means that the view must provide a prefix for that value.
      Parameters:
      a -
      b -
      Returns:
    • deriveViewLookupConstraint

      public static VariableConstraint deriveViewLookupConstraint(org.apache.jena.sparql.expr.Expr expr)
      Returns IsPrefixOf Constraints for equality expressions between variables and constants. Used for looking up view candidates. Not used for satisfiability checks.
      Parameters:
      expr -
      Returns:
    • getApplicableViewsBase

      public List<SparqlViewConjunction> getApplicableViewsBase(org.apache.jena.sparql.algebra.op.OpQuadPattern op, RestrictionManagerImpl restrictions)
      Order the quads of the quadPattern by selectivity. Iterate the quads in order, and for each quad, do a lookup of the views that may yield answers to it. So for each quad we get a set of candidate bindings to the views. Binding is a mapping from query-var to a set of view variables/constant The view varibale may have constraints on it, which carry over to the query variable. So given Create View x ... {?x a Class . } With ?x.value prefix "foo" a query Select {?s ?p ?o } and a binding(?s = ?x), then we can infer the constraint on ?x.value prefix "foo" So if there is a second pattern { ?x a Class. ?x label ?z } Then we can use this constraint on the lookup at the second pattern. Note that the selectivity of query quad pattern change with the bindings, so we should be able to quickly update the selectivity of the quads in the presence of bindings. Another note: Maybe we could treat constants as specially delimited prefixes, such as 'aaaa' = prefix 'aaaaa$' = constant
    • findCandidates

      public Set<org.aksw.sparqlify.sparqlview.ViewQuad> findCandidates(org.apache.jena.sparql.core.Quad quad, RestrictionManagerImpl restrictions)
    • findQuadWithFewestViewCandidates

      public org.aksw.commons.util.Pair<NavigableMap<Integer,Set<org.apache.jena.sparql.core.Quad>>,Map<org.apache.jena.sparql.core.Quad,Set<org.aksw.sparqlify.sparqlview.ViewQuad>>> findQuadWithFewestViewCandidates(org.apache.jena.sparql.core.QuadPattern queryQuads, RestrictionManagerImpl restrictions)
    • getCandidateNames

      public static List<String> getCandidateNames(org.aksw.commons.collections.stacks.NestedStack<SparqlViewInstance> instances)
    • getApplicableViewsRec2

      public void getApplicableViewsRec2(int index, List<org.apache.jena.sparql.core.Quad> quadOrder, Set<org.aksw.sparqlify.sparqlview.ViewQuad> viewQuads, Map<org.apache.jena.sparql.core.Quad,Set<org.aksw.sparqlify.sparqlview.ViewQuad>> candidates, RestrictionManagerImpl restrictions, org.aksw.commons.collections.stacks.NestedStack<SparqlViewInstance> instances, List<SparqlViewConjunction> result)
      Parameters:
      index -
      quadOrder -
      viewQuads - The viewQuads provided by the parent invocation - with any restrictions encountered during the rewrite taken into account
      candidates - The viewQuads here are the ones from only analyzing the query filter In some cases (small candidate sets) it might be faster filtering this set of view candidates, rather than doing a new lookup.
      restrictions -
      result -
    • getApplicableViews

      public org.apache.jena.sparql.algebra.Op getApplicableViews(org.apache.jena.sparql.algebra.op.OpQuadPattern op, RestrictionManagerImpl restrictions)
    • isSatisfiable

      public static boolean isSatisfiable(List<SparqlViewInstance> list)
    • _getApplicableViews

      public org.apache.jena.sparql.algebra.Op _getApplicableViews(org.apache.jena.sparql.algebra.Op op)
      Given a sparql query in quad form, this method replaces (sub sets of) quad patterns with view instances (view patterns) The method also passes the filter conditions that an op must satisfy.
      Parameters:
      op -
      Returns:
    • _getApplicableViews

      public org.apache.jena.sparql.algebra.Op _getApplicableViews(org.apache.jena.sparql.algebra.Op op, RestrictionManagerImpl restrictions)
    • getApplicableViews

      public org.apache.jena.sparql.algebra.Op getApplicableViews(org.apache.jena.sparql.algebra.op.OpProject op, RestrictionManagerImpl restrictions)
    • getApplicableViews

      public org.apache.jena.sparql.algebra.Op getApplicableViews(org.apache.jena.sparql.algebra.op.OpOrder op, RestrictionManagerImpl restrictions)
    • getApplicableViews

      public org.apache.jena.sparql.algebra.Op getApplicableViews(org.apache.jena.sparql.algebra.op.OpGroup op, RestrictionManagerImpl restrictions)
    • getApplicableViews

      public org.apache.jena.sparql.algebra.Op getApplicableViews(org.apache.jena.sparql.algebra.op.OpExtend op, RestrictionManagerImpl _restrictions)
    • getApplicableViews

      public org.apache.jena.sparql.algebra.Op getApplicableViews(org.apache.jena.sparql.algebra.op.OpFilter op, RestrictionManagerImpl restrictions)
    • getApplicableViews

      public org.apache.jena.sparql.algebra.Op getApplicableViews(org.apache.jena.sparql.algebra.op.OpUnion op, RestrictionManagerImpl restrictions)
    • getApplicableViews

      public org.apache.jena.sparql.algebra.Op getApplicableViews(org.apache.jena.sparql.algebra.op.OpJoin op, RestrictionManagerImpl restrictions)
    • getApplicableViews

      public org.apache.jena.sparql.algebra.Op getApplicableViews(org.apache.jena.sparql.algebra.op.OpLeftJoin op, RestrictionManagerImpl restrictions)
    • getApplicableViews

      public org.apache.jena.sparql.algebra.Op getApplicableViews(org.apache.jena.sparql.algebra.op.OpSlice op, RestrictionManagerImpl restrictions)
    • getApplicableViews

      public org.apache.jena.sparql.algebra.Op getApplicableViews(org.apache.jena.sparql.algebra.op.OpDistinct op, RestrictionManagerImpl restrictions)
    • getRestrictions2

      public static RestrictionManagerImpl getRestrictions2(org.apache.jena.sparql.algebra.Op op)
    • getRestrictions

      public static List<RestrictionManagerImpl> getRestrictions(org.apache.jena.sparql.algebra.Op op)
    • getRestrictions

      public static void getRestrictions(org.apache.jena.sparql.algebra.Op op, Collection<RestrictionManagerImpl> result)
      Returns a disjunction (list) of restrictions that apply for a given node
    • getViews

      public Collection<SparqlView> getViews()