Class DataQueryImpl<T extends org.apache.jena.rdf.model.RDFNode>

java.lang.Object
org.aksw.jena_sparql_api.data_query.impl.DataQueryImpl<T>
All Implemented Interfaces:
DataQuery<T>
Direct Known Subclasses:
FacetedDataQueryImpl

public class DataQueryImpl<T extends org.apache.jena.rdf.model.RDFNode> extends Object implements DataQuery<T>
Optional paths Given the following graph patterns, are the some algebraic relations that hold between them? (a) { OPTIONAL { X } } (b) { OPTIONAL { X OPTIONAL Y } } (c) { OPTIONAL { X Y } } c: If for some binding of X there is no suitable binding of Y, the whole binding will be dropped Maybe optional should be part of the traversal api? fwd('foo').opt().fwd('bar')
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.jena.sparql.syntax.Element
    grouped mode (false): default semantic of construct queries partition mode (true): each row is individually mapped to a resource, used for facet value counts
    protected List<DataNode>
     
    protected org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource
     
    protected org.apache.jena.sparql.core.Var
    filter/only affect this variable by default convenient if there is more than one primary key variable,
    protected List<org.apache.jena.sparql.syntax.Element>
     
    protected org.aksw.jenax.sparql.fragment.api.Fragment1
     
    protected Long
     
    protected Long
     
    protected boolean
     
    protected List<org.apache.jena.sparql.core.Var>
     
    protected Set<Path>
     
    protected Random
     
    protected boolean
     
    protected Class<T>
     
    protected boolean
     
    protected List<org.apache.jena.query.SortCondition>
     
    protected org.apache.jena.graph.Node
     
    protected org.apache.jena.sparql.syntax.Template
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DataQueryImpl(org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource dataSource, org.aksw.jenax.sparql.fragment.api.Fragment1 baseRelation, org.apache.jena.sparql.syntax.Template template, Class<T> resultClass)
     
    DataQueryImpl(org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource dataSource, org.apache.jena.sparql.syntax.Element baseElement, List<org.apache.jena.sparql.core.Var> primaryKeyVars, org.apache.jena.graph.Node superRootNode, org.apache.jena.sparql.core.Var defaultVar, org.apache.jena.sparql.syntax.Template template, Class<T> resultClass)
     
    DataQueryImpl(org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource dataSource, org.apache.jena.sparql.syntax.Element baseQueryPattern, org.apache.jena.sparql.core.Var rootVar, org.apache.jena.sparql.syntax.Template template, Class<T> resultClass)
     
    DataQueryImpl(org.apache.jena.rdfconnection.SparqlQueryConnection conn, org.aksw.jenax.sparql.fragment.api.Fragment1 baseRelation, org.apache.jena.sparql.syntax.Template template, Class<T> resultClass)
    Deprecated.
    DataQueryImpl(org.apache.jena.rdfconnection.SparqlQueryConnection conn, org.apache.jena.sparql.syntax.Element baseElement, List<org.apache.jena.sparql.core.Var> primaryKeyVars, org.apache.jena.graph.Node superRootNode, org.apache.jena.sparql.core.Var defaultVar, org.apache.jena.sparql.syntax.Template template, Class<T> resultClass)
    Deprecated.
    DataQueryImpl(org.apache.jena.rdfconnection.SparqlQueryConnection conn, org.apache.jena.sparql.syntax.Element baseQueryPattern, org.apache.jena.sparql.core.Var rootVar, org.apache.jena.sparql.syntax.Template template, Class<T> resultClass)
    Deprecated.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(org.apache.jena.rdf.model.Property property)
     
    addOptional(org.apache.jena.rdf.model.Property property)
     
    addOrderBy(Path path, int direction)
     
    addOrderBy(org.apache.jena.graph.Node node, int direction)
    A template resolver enables traversal of the template and injection of further triple patterns.
    static org.apache.jena.sparql.syntax.Template
    applyNodeTransform(org.apache.jena.sparql.syntax.Template template, org.apache.jena.sparql.graph.NodeTransform xform)
     
    <U extends org.apache.jena.rdf.model.RDFNode>
    DataQuery<U>
    as(Class<U> clazz)
     
    org.apache.jena.sparql.syntax.Element
     
    io.reactivex.rxjava3.core.Single<org.aksw.commons.util.range.CountInfo>
     
    io.reactivex.rxjava3.core.Single<org.aksw.commons.util.range.CountInfo>
    count(Long distinctItemCount, Long rowCount)
     
    org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource
     
    dataSource(org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource dataSource)
     
    io.reactivex.rxjava3.core.Flowable<T>
     
    io.reactivex.rxjava3.core.Single<org.apache.jena.rdf.model.Model>
     
    org.aksw.jenax.sparql.fragment.impl.Concept
     
    filter(org.aksw.jenax.sparql.fragment.api.Fragment1 concept)
     
    filter(org.apache.jena.sparql.expr.Expr expr)
     
    filterDirect(org.apache.jena.sparql.syntax.Element element)
     
    filterUsing(org.aksw.jenax.sparql.fragment.api.Fragment relation, String... attrNames)
    Join the base element on vars corresponding to attrName with another relation Method is subject to be replaced with a more general mechanism based on Relationlets
    get(String attr)
    Hibernate-like get method which resolves an attribute of the resultClass to a SPARQL variable of the underlying partitioned query's template The result is a Node that can be used in Jena SPARQL Expr expressions, which can be subsequently passed to e.g.
    getAttr(String attrName)
     
    org.apache.jena.sparql.core.Var
     
    List<org.apache.jena.sparql.core.Var>
     
     
    org.apache.jena.graph.Node
     
    boolean
     
    boolean
     
    boolean
     
    limit(Long limit)
     
    org.apache.jena.graph.Node
     
    offset(Long offset)
     
    ordered(boolean onOrOff)
     
    peek(Consumer<? super DataQuery<T>> consumer)
     
    List<org.apache.jena.sparql.core.Var>
     
    pseudoRandom(Random pseudoRandom)
    Setting a random number generator (rng) makes query execution deterministic: Random effects on result sets will be processed in the client: Randomly ordered result sets will be fully loaded into the client and shuffeled in respect to the given rng.
    randomOrder(boolean onOrOff)
     
    org.apache.jena.sparql.core.Var
     
     
    sample(boolean onOrOff)
     
     
    static List<Map.Entry<org.apache.jena.sparql.path.P_Path0,String>>
    Strip a path from steps of non-basic steps, such as optional ones.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.aksw.jena_sparql_api.data_query.api.DataQuery

    baseRelation, connection, connection, exclude, exclude, exclude, exclude, filter, limit, offset, only, only, only, only, ordered, randomOrder, sample, toConstructQuery
  • Field Details

    • dataSource

      protected org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource dataSource
    • baseElement

      protected org.apache.jena.sparql.syntax.Element baseElement
      grouped mode (false): default semantic of construct queries partition mode (true): each row is individually mapped to a resource, used for facet value counts
    • primaryKeyVars

      protected List<org.apache.jena.sparql.core.Var> primaryKeyVars
    • superRootNode

      protected org.apache.jena.graph.Node superRootNode
    • defaultVar

      protected org.apache.jena.sparql.core.Var defaultVar
      filter/only affect this variable by default convenient if there is more than one primary key variable,
    • template

      protected org.apache.jena.sparql.syntax.Template template
    • dataNodes

      protected List<DataNode> dataNodes
    • limit

      protected Long limit
    • offset

      protected Long offset
    • filter

      protected org.aksw.jenax.sparql.fragment.api.Fragment1 filter
    • directFilters

      protected List<org.apache.jena.sparql.syntax.Element> directFilters
    • ordered

      protected boolean ordered
    • randomOrder

      protected boolean randomOrder
    • sample

      protected boolean sample
    • pseudoRandom

      protected Random pseudoRandom
    • resultClass

      protected Class<T extends org.apache.jena.rdf.model.RDFNode> resultClass
    • sortConditions

      protected List<org.apache.jena.query.SortCondition> sortConditions
    • projectedPaths

      protected Set<Path> projectedPaths
  • Constructor Details

    • DataQueryImpl

      public DataQueryImpl(org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource dataSource, org.aksw.jenax.sparql.fragment.api.Fragment1 baseRelation, org.apache.jena.sparql.syntax.Template template, Class<T> resultClass)
    • DataQueryImpl

      public DataQueryImpl(org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource dataSource, org.apache.jena.sparql.syntax.Element baseQueryPattern, org.apache.jena.sparql.core.Var rootVar, org.apache.jena.sparql.syntax.Template template, Class<T> resultClass)
    • DataQueryImpl

      public DataQueryImpl(org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource dataSource, org.apache.jena.sparql.syntax.Element baseElement, List<org.apache.jena.sparql.core.Var> primaryKeyVars, org.apache.jena.graph.Node superRootNode, org.apache.jena.sparql.core.Var defaultVar, org.apache.jena.sparql.syntax.Template template, Class<T> resultClass)
    • DataQueryImpl

      @Deprecated public DataQueryImpl(org.apache.jena.rdfconnection.SparqlQueryConnection conn, org.aksw.jenax.sparql.fragment.api.Fragment1 baseRelation, org.apache.jena.sparql.syntax.Template template, Class<T> resultClass)
      Deprecated.
    • DataQueryImpl

      @Deprecated public DataQueryImpl(org.apache.jena.rdfconnection.SparqlQueryConnection conn, org.apache.jena.sparql.syntax.Element baseQueryPattern, org.apache.jena.sparql.core.Var rootVar, org.apache.jena.sparql.syntax.Template template, Class<T> resultClass)
      Deprecated.
    • DataQueryImpl

      @Deprecated public DataQueryImpl(org.apache.jena.rdfconnection.SparqlQueryConnection conn, org.apache.jena.sparql.syntax.Element baseElement, List<org.apache.jena.sparql.core.Var> primaryKeyVars, org.apache.jena.graph.Node superRootNode, org.apache.jena.sparql.core.Var defaultVar, org.apache.jena.sparql.syntax.Template template, Class<T> resultClass)
      Deprecated.
  • Method Details

    • as

      public <U extends org.apache.jena.rdf.model.RDFNode> DataQuery<U> as(Class<U> clazz)
      Specified by:
      as in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • dataSource

      public org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource dataSource()
      Specified by:
      dataSource in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • dataSource

      public DataQuery<T> dataSource(org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource dataSource)
      Specified by:
      dataSource in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • getDefaultVar

      public org.apache.jena.sparql.core.Var getDefaultVar()
      Specified by:
      getDefaultVar in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • limit

      public DataQuery<T> limit(Long limit)
      Specified by:
      limit in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • offset

      public DataQuery<T> offset(Long offset)
      Specified by:
      offset in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • sample

      public DataQuery<T> sample(boolean onOrOff)
      Specified by:
      sample in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • isSampled

      public boolean isSampled()
      Specified by:
      isSampled in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • ordered

      public DataQuery<T> ordered(boolean onOrOff)
      Specified by:
      ordered in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • isOrdered

      public boolean isOrdered()
      Specified by:
      isOrdered in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • isRandomOrder

      public boolean isRandomOrder()
      Specified by:
      isRandomOrder in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • randomOrder

      public DataQuery<T> randomOrder(boolean onOrOff)
      Specified by:
      randomOrder in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • pseudoRandom

      public DataQuery<T> pseudoRandom(Random pseudoRandom)
      Setting a random number generator (rng) makes query execution deterministic: Random effects on result sets will be processed in the client: Randomly ordered result sets will be fully loaded into the client and shuffeled in respect to the given rng. TODO We may need extra an extra 'deterministic' attribute to indicate whether to sort result sets - the problem is, that the same query on data loaded at different times may yield different results. For practical purposes it rarely happens that the same query yields different results if there were no changes in the data. But maybe it could happen if a DB did something similar to postgres' vacuum process?
      Specified by:
      pseudoRandom in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
      Parameters:
      pseudoRandom -
      Returns:
    • fetchPredicates

      public org.aksw.jenax.sparql.fragment.impl.Concept fetchPredicates()
      Specified by:
      fetchPredicates in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • getRoot

      public DataNode getRoot()
      Specified by:
      getRoot in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • addOptional

      public DataQuery<T> addOptional(org.apache.jena.rdf.model.Property property)
      Specified by:
      addOptional in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • add

      public DataQuery<T> add(org.apache.jena.rdf.model.Property property)
      Specified by:
      add in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • filter

      public DataQuery<T> filter(org.aksw.jenax.sparql.fragment.api.Fragment1 concept)
      Specified by:
      filter in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • filterDirect

      public DataQuery<T> filterDirect(org.apache.jena.sparql.syntax.Element element)
      Specified by:
      filterDirect in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • peek

      public DataQuery<T> peek(Consumer<? super DataQuery<T>> consumer)
      Specified by:
      peek in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • filterUsing

      public DataQuery<T> filterUsing(org.aksw.jenax.sparql.fragment.api.Fragment relation, String... attrNames)
      Join the base element on vars corresponding to attrName with another relation Method is subject to be replaced with a more general mechanism based on Relationlets
      Specified by:
      filterUsing in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • resolveAttrToVar

      public org.apache.jena.sparql.core.Var resolveAttrToVar(String attr)
    • get

      public NodePath get(String attr)
      Hibernate-like get method which resolves an attribute of the resultClass to a SPARQL variable of the underlying partitioned query's template The result is a Node that can be used in Jena SPARQL Expr expressions, which can be subsequently passed to e.g. filter(expr) of this class for filtering.
      Specified by:
      get in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • filter

      public DataQuery<T> filter(org.apache.jena.sparql.expr.Expr expr)
      Specified by:
      filter in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • getSuperRootNode

      public org.apache.jena.graph.Node getSuperRootNode()
      Specified by:
      getSuperRootNode in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • getPrimaryKeyVars

      public List<org.apache.jena.sparql.core.Var> getPrimaryKeyVars()
    • toConstructQueryNew

      public QuerySpec toConstructQueryNew()
      Specified by:
      toConstructQueryNew in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • applyNodeTransform

      public static org.apache.jena.sparql.syntax.Template applyNodeTransform(org.apache.jena.sparql.syntax.Template template, org.apache.jena.sparql.graph.NodeTransform xform)
    • toSimpleSteps

      public static List<Map.Entry<org.apache.jena.sparql.path.P_Path0,String>> toSimpleSteps(Path path)
      Strip a path from steps of non-basic steps, such as optional ones.
    • exec

      public io.reactivex.rxjava3.core.Flowable<T> exec()
      Specified by:
      exec in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • addOrderBy

      public DataQuery<T> addOrderBy(org.apache.jena.graph.Node node, int direction)
      A template resolver enables traversal of the template and injection of further triple patterns. So essentially it is the Resource API with the addition of allowing DataResolution references.
      Specified by:
      addOrderBy in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • addOrderBy

      public DataQuery<T> addOrderBy(Path path, int direction)
      Specified by:
      addOrderBy in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • baseElement

      public org.apache.jena.sparql.syntax.Element baseElement()
      Specified by:
      baseElement in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • primaryKeyVars

      public List<org.apache.jena.sparql.core.Var> primaryKeyVars()
      Specified by:
      primaryKeyVars in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • execConstruct

      public io.reactivex.rxjava3.core.Single<org.apache.jena.rdf.model.Model> execConstruct()
      Specified by:
      execConstruct in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • count

      public io.reactivex.rxjava3.core.Single<org.aksw.commons.util.range.CountInfo> count()
      Specified by:
      count in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • count

      public io.reactivex.rxjava3.core.Single<org.aksw.commons.util.range.CountInfo> count(Long distinctItemCount, Long rowCount)
      Specified by:
      count in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • resolver

      public ResolverNode resolver()
      Specified by:
      resolver in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • nodeForPath

      public org.apache.jena.graph.Node nodeForPath(Path path)
      Specified by:
      nodeForPath in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>
    • getAttr

      public DataQueryVarView<T> getAttr(String attrName)
      Specified by:
      getAttr in interface DataQuery<T extends org.apache.jena.rdf.model.RDFNode>