Class FacetedQueryGenerator<P>

java.lang.Object
org.aksw.jena_sparql_api.data_query.impl.FacetedQueryGenerator<P>

public class FacetedQueryGenerator<P> extends Object
  • Field Details

  • Constructor Details

    • FacetedQueryGenerator

      public FacetedQueryGenerator(PathAccessor<P> pathAccessor)
  • Method Details

    • createNodeTransformSubstitutePathReferences

      public static <P> org.apache.jena.sparql.graph.NodeTransform createNodeTransformSubstitutePathReferences(PathToRelationMapper<P> mapper, PathAccessor<P> pathAccessor)
    • addConstraint

      public void addConstraint(org.apache.jena.sparql.expr.Expr expr)
    • setBaseConcept

      public void setBaseConcept(Fragment1 baseConcept)
    • hideConstraintsForPath

      public com.google.common.collect.SetMultimap<P,org.apache.jena.sparql.expr.Expr> hideConstraintsForPath(com.google.common.collect.SetMultimap<P,org.apache.jena.sparql.expr.Expr> constaintIndex, P path)
    • toSimplePath

      public static <T> org.aksw.jenax.sparql.path.SimplePath toSimplePath(T path, PathAccessor<T> pathAccessor)
    • createRelationForPath

      public static <P> Fragment2 createRelationForPath(PathToRelationMapper<P> mapper, PathAccessor<P> pathAccessor, P childPath, boolean includeAbsent)
    • createRelationForPath

      public Fragment2 createRelationForPath(P childPath, com.google.common.collect.SetMultimap<P,org.apache.jena.sparql.expr.Expr> constraintIndex, boolean applySelfConstraints, boolean negated, boolean includeAbsent)
      Creates the relation for the path given as the first argument
      Parameters:
      childPath -
      constraintIndex -
      constraints -
      negated -
      Returns:
    • getRemainingFacets

      public Fragment2 getRemainingFacets(P focusPath, P facetOriginPath, boolean isReverse, com.google.common.collect.SetMultimap<P,org.apache.jena.sparql.expr.Expr> constraintIndex, boolean negated, boolean includeAbsent)
    • getRemainingFacetsWithAbsent

      public Fragment2 getRemainingFacetsWithAbsent(P focusPath, P facetOriginPath, boolean isReverse, com.google.common.collect.SetMultimap<P,org.apache.jena.sparql.expr.Expr> constraintIndex, boolean negated)
    • getRemainingFacetsWithoutAbsent

      public Fragment2 getRemainingFacetsWithoutAbsent(P facetOriginPath, boolean isReverse, com.google.common.collect.SetMultimap<P,org.apache.jena.sparql.expr.Expr> constraintIndex, boolean negated, boolean includeAbsent)
    • containsAbsent

      public static boolean containsAbsent(Collection<? extends org.apache.jena.sparql.expr.Expr> exprs)
    • compareAbsent

      public static int compareAbsent(org.apache.jena.sparql.expr.Expr a, org.apache.jena.sparql.expr.Expr b)
    • compareAbsent

      public static int compareAbsent(Collection<? extends org.apache.jena.sparql.expr.Expr> a, Collection<? extends org.apache.jena.sparql.expr.Expr> b)
    • isAbsent

      public static boolean isAbsent(org.apache.jena.sparql.expr.Expr expr)
    • internalRewriteAbsent

      public static org.apache.jena.sparql.expr.Expr internalRewriteAbsent(org.apache.jena.sparql.expr.Expr expr)
    • allocatePathRelations

      public static <P> Map<P,Fragment2> allocatePathRelations(PathToRelationMapper<P> mapper, PathAccessor<P> pathAccessor, com.google.common.collect.Multimap<P,org.apache.jena.sparql.expr.Expr> constraintIndex)
    • createElementsForExprs

      public static <P> Collection<org.apache.jena.sparql.syntax.Element> createElementsForExprs(PathToRelationMapper<P> mapper, PathAccessor<P> pathAccessor, Collection<org.apache.jena.sparql.expr.Expr> constraints, boolean negate)
      Creates elements from the given constraint expressions. This method collects all paths referenced in the expressions and allocates their relations. Used by DataQueryImpl::filter
      Parameters:
      mapper -
      pathAccessor -
      constraints -
      negate -
      Returns:
    • createElementsForExprs

      public static <P> Collection<org.apache.jena.sparql.syntax.Element> createElementsForExprs(PathToRelationMapper<P> mapper, PathAccessor<P> pathAccessor, Map<P,Fragment2> pathToRelation, Collection<org.apache.jena.sparql.expr.Expr> baseExprs, boolean negate)
    • createConstraintRelationForPath

      public Fragment2 createConstraintRelationForPath(P rootPath, P childPath, Fragment2 facetRelation, org.apache.jena.sparql.core.Var pVar, com.google.common.collect.Multimap<P,org.apache.jena.sparql.expr.Expr> constraintIndex, boolean negate, boolean includeAbsent)
      Returns a binary relation with facet - facet value columns. Attemps to rename variables of the facetRelation as to not conflict with the variables of paths. Issue: facetRelation is not relative to basePath but to root, so the connection variable is that of root
      Parameters:
      rootPath - only used to obtain the connecting variable
      facetRelation -
      pVar -
      effectiveConstraints -
      negate - Negate the constraints - this yields all facet+values unaffected by the effectiveConstraints do NOT apply
      Returns:
    • createConceptFacets

      public static Fragment1 createConceptFacets(Map<String,Fragment3> relations, Concept pConstraint)
    • createConceptFacetsOld

      @Deprecated public static Fragment1 createConceptFacetsOld(Map<String,Fragment2> relations, Concept pConstraint)
      Deprecated.
    • createRelationFacetsAndCounts

      public static Fragment2 createRelationFacetsAndCounts(Map<String,Fragment3> relationsFocusFacetValue, Concept pConstraint, boolean includeAbsent, boolean focusCount)
    • createRelationFacetsAndCountsOld

      @Deprecated public static Fragment2 createRelationFacetsAndCountsOld(Map<String,Fragment2> relations, Concept pConstraint, boolean includeAbsent)
      Deprecated.
    • isExprExcluded

      @Deprecated public boolean isExprExcluded(org.apache.jena.sparql.expr.Expr expr, P path, boolean isReverse)
      Deprecated.
      Create helper functions for filtering out the expressions that do not apply for a given path
    • createMapFacetsAndValues

      public Map<String,Fragment2> createMapFacetsAndValues(P focusPath, P facetOriginPath, boolean isReverse, boolean applySelfConstraints, boolean negated, boolean includeAbsent)
      For the give path and direction, yield a map of binary relations for the corresponding facets. An entry with key null indicates the predicate / distinct value count pairs with all constraints in place
      Parameters:
      facetOriginPath -
      isReverse -
      Returns:
    • createRelationFacetValue

      public Fragment3 createRelationFacetValue(P focus, P facetPath, boolean isReverse, Fragment1 pFilter, Fragment1 oFilter, boolean applySelfConstraints, boolean includeAbsent)
    • createRelationFacetValueTypeCounts

      public Fragment3 createRelationFacetValueTypeCounts(P focus, P facetPath, boolean isReverse, boolean negated, Fragment1 pFilter, Fragment1 oFilter, boolean includeAbsent)
      A modification of facet value counts that instead of the values yields the values' types. Useful for description logics stuff, as it yields the 'Cs' in "exists r.C"
      Parameters:
      focus -
      facetPath -
      isReverse -
      negated -
      pFilter -
      oFilter -
      includeAbsent -
      Returns:
    • createRelationFacetValueCounts

      public Fragment3 createRelationFacetValueCounts(P focus, P facetPath, boolean isReverse, boolean negated, Fragment1 pFilter, Fragment1 oFilter, boolean includeAbsent)
    • getRoot

      public static <T> T getRoot(T item, Function<? super T,? extends T> getParent)
    • getConstraintExpr

      public ExprFragment getConstraintExpr(P facetPath, boolean isReverse)
      Yields a filter expression that excludes all (facet, facetValue) pairs which are affected by filters. Conversely, filtering facetAndValues by this expression yields only those items from which new constraints can be created.
      Parameters:
      facetPath -
      isReverse -
      Returns:
    • extractChildPaths

      public Set<P> extractChildPaths(P basePath, boolean isReverse, Collection<P> candidates)
      Given a collection of paths, yield those that are a direct successor of 'basePath' in the direction specified by 'isReverse'.
      Parameters:
      basePath -
      isReverse -
      candidates -
      Returns:
    • indexConstraints

      public static <P> com.google.common.collect.SetMultimap<P,org.apache.jena.sparql.expr.Expr> indexConstraints(PathAccessor<P> pathAccessor, Collection<org.apache.jena.sparql.expr.Expr> constraints)
      Indexing of constraints groups those that apply to the same same path(s). This serves as the base for combination using logical junctors and/or.
      Parameters:
      basePath -
      applySelfConstraints -
      Returns:
    • createElementsFromConstraintIndex

      public Set<org.apache.jena.sparql.syntax.Element> createElementsFromConstraintIndex(com.google.common.collect.Multimap<P,org.apache.jena.sparql.expr.Expr> constraintIndex, Predicate<? super P> negatePath)
      This method is called in the context of creating the element for a path It enables negating the constraints on that path
      Parameters:
      constraintIndex -
      Returns:
    • getConceptForAtPath

      public Fragment1 getConceptForAtPath(P focusPath, P facetPath, boolean applySelfConstraints)
    • getFacetValuesCore

      public Map<String,Fragment3> getFacetValuesCore(Fragment1 baseConcept, P focusPath, P facetPath, Fragment1 pFilter, Fragment1 oFilter, boolean isReverse, boolean negated, boolean applySelfConstraints, boolean includeAbsent)
    • createConceptFacets

      public static Concept createConceptFacets(Fragment3 tr)
      Simply create a concept from the predicate column of the ternary relation. TODO Possibly supersede by using a TernaryRelation.getConceptP() method.
      Parameters:
      tr -
      Returns:
    • countFacetValues

      public static Fragment3 countFacetValues(Fragment3 tr, int sortDirection)
      Returns: