Class DistinctExtendFilter2

java.lang.Object
org.aksw.jena_sparql_api.algebra.analysis.DistinctExtendFilter2

public class DistinctExtendFilter2 extends Object
This class captures the following generic SPARQL query set: Select (project / extend) { // postDistinctVarDefs select distinct (project / extend) { // preDestinctVarDefs [subOp] filter(...) } } - if there is no distinct, there are no post-distinct definitions (indicated by null); only pre-distinct ones - the filters are always expressed to reference pre-distinct variables this means, that any filter must be expanded first using the post-distinct definitions and subsequently the pre-distsinct definitions - initially: as long as there is no distinct encountered: - have all projections / expressions affect the pre-distinct definitions When encountering distinct: - Any new distinct makes a prior one obsolete. - The postDistinct expressions become simply identity mappings of the pre-distinct definitions Note: It is possible to have nested distinct's that cannot be flattened, such as: Extend(?foo = , Distinct(?s ... )
Author:
raven
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected ExprHolder
     
    protected boolean
     
    protected Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr>
     
    protected Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DistinctExtendFilter2(Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> varToDef, boolean distinct, ExprHolder filter)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Conceptually overrides a prior distinct, and marks all so far visible variables as distinct - If there was no prior distinct: Initialize the post distinct map to an identity mapping of the visible variables after pre-distinct - Otherwise Merge the current post-distinct definitions with the pre-distinct ones: Create a post-distinct identity mapping with all visible variables of pre-distinct
    applyExtend(Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> extend)
     
    applyExtend(org.apache.jena.sparql.core.VarExprList extend)
     
    applyFilter(org.apache.jena.sparql.expr.Expr contribExpr)
    Expand any filter according to any prior extend
    applyFilter(org.apache.jena.sparql.expr.ExprList contribExprs)
     
    applyProject(Collection<org.apache.jena.sparql.core.Var> projectVars)
    Update the projection
     
    create(Collection<org.apache.jena.sparql.core.Var> initialVars)
     
    static org.apache.jena.sparql.expr.ExprTransform
    createExprTransform(Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> varDefs)
     
    static Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr>
    createIdentityMap(Collection<org.apache.jena.sparql.core.Var> vars)
     
    static Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr>
    expandDefs(Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> src, Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> varDefs)
     
    org.apache.jena.sparql.expr.Expr
    expandExpr(org.apache.jena.sparql.expr.Expr expr)
     
    static org.apache.jena.sparql.expr.Expr
    expandExpr(org.apache.jena.sparql.expr.Expr expr, Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> varDefs)
     
    static void
    main(String[] args)
     
    org.apache.jena.sparql.algebra.Op
    toOp(org.apache.jena.sparql.algebra.Op result)
     
     
    static String
    toString(Map.Entry<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> e)
     
    static String
    toString(Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> varDefs)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • postDistinctVarDefs

      protected Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> postDistinctVarDefs
    • isDistinct

      protected boolean isDistinct
    • preDistinctVarDefs

      protected Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> preDistinctVarDefs
    • filter

      protected ExprHolder filter
  • Constructor Details

    • DistinctExtendFilter2

      public DistinctExtendFilter2(Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> varToDef, boolean distinct, ExprHolder filter)
  • Method Details

    • toOp

      public org.apache.jena.sparql.algebra.Op toOp(org.apache.jena.sparql.algebra.Op result)
    • create

      public static DistinctExtendFilter2 create()
    • createIdentityMap

      public static Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> createIdentityMap(Collection<org.apache.jena.sparql.core.Var> vars)
    • create

      public static DistinctExtendFilter2 create(Collection<org.apache.jena.sparql.core.Var> initialVars)
    • applyProject

      public DistinctExtendFilter2 applyProject(Collection<org.apache.jena.sparql.core.Var> projectVars)
      Update the projection
      Parameters:
      projectVars -
      Returns:
    • applyDistinct

      public DistinctExtendFilter2 applyDistinct()
      Conceptually overrides a prior distinct, and marks all so far visible variables as distinct - If there was no prior distinct: Initialize the post distinct map to an identity mapping of the visible variables after pre-distinct - Otherwise Merge the current post-distinct definitions with the pre-distinct ones: Create a post-distinct identity mapping with all visible variables of pre-distinct
      Returns:
    • applyExtend

      public DistinctExtendFilter2 applyExtend(org.apache.jena.sparql.core.VarExprList extend)
    • applyExtend

      public DistinctExtendFilter2 applyExtend(Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> extend)
    • applyFilter

      public DistinctExtendFilter2 applyFilter(org.apache.jena.sparql.expr.ExprList contribExprs)
    • applyFilter

      public DistinctExtendFilter2 applyFilter(org.apache.jena.sparql.expr.Expr contribExpr)
      Expand any filter according to any prior extend
      Parameters:
      exprHolder -
      Returns:
    • toString

      public static String toString(Map.Entry<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> e)
    • toString

      public static String toString(Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> varDefs)
    • toString

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

      public org.apache.jena.sparql.expr.Expr expandExpr(org.apache.jena.sparql.expr.Expr expr)
    • expandDefs

      public static Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> expandDefs(Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> src, Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> varDefs)
    • createExprTransform

      public static org.apache.jena.sparql.expr.ExprTransform createExprTransform(Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> varDefs)
    • expandExpr

      public static org.apache.jena.sparql.expr.Expr expandExpr(org.apache.jena.sparql.expr.Expr expr, Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.expr.Expr> varDefs)
    • main

      public static void main(String[] args)