Class EntityQueryRx

java.lang.Object
org.aksw.jena_sparql_api.rx.entity.engine.EntityQueryRx

public class EntityQueryRx extends Object
Methods for the execution of EntityQueryBasics
Author:
raven
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <ITEM, KEY, VALUE>
    io.reactivex.rxjava3.core.FlowableTransformer<ITEM,Map.Entry<KEY,VALUE>>
    aggregateConsecutiveItemsWithSameKey(Function<? super ITEM,KEY> itemToKey, org.aksw.commons.collector.domain.Aggregator<? super ITEM,?,VALUE> aggregator)
    A generic flowable transformer that groups consecutive items that evaluate to the same key.
    Create a transformed copy of the query where all variables that need to join have the same name whereas variables that are not supposed to join have been remapped
     
    createGraphAggregator(org.apache.jena.sparql.syntax.Template template, Set<? extends org.apache.jena.graph.Node> trackedTemplateNodes, Map<org.apache.jena.graph.Node,org.apache.jena.sparql.expr.ExprList> idMap, ExprListEval exprListEval, Supplier<org.apache.jena.graph.Graph> graphSupplier)
    Create an aggregator whose accumulators accumulate graphs from Bindings w.r.t.
    static Function<org.apache.jena.sparql.engine.binding.Binding,org.apache.jena.graph.Node>
    createKeyFunction(org.apache.jena.graph.Node root, Map<org.apache.jena.graph.Node,org.apache.jena.sparql.expr.ExprList> idMapping, ExprListEval exprListEval)
    Based on the information present in EntityQueryBasic return a function that deterministically yields the same node (possibly a blank node) when passing equivalent bindings to it.
    static List<org.apache.jena.query.SortCondition>
    createSortConditionsFromExprs(Iterable<org.apache.jena.sparql.expr.Expr> exprs, int dir)
    Create sort conditions with the given directions from an iterable of Exprs
    static List<org.apache.jena.query.SortCondition>
    createSortConditionsFromVars(Iterable<org.apache.jena.sparql.core.Var> vars, int dir)
    Util function to create sort conditions from variables and a direction
    static Function<org.apache.jena.sparql.algebra.Table,AggObjectGraph.AccObjectGraph>
    createTableToGraphMapper(org.apache.jena.sparql.syntax.Template template, Set<? extends org.apache.jena.graph.Node> trackedTemplateNodes, Map<org.apache.jena.graph.Node,org.apache.jena.sparql.expr.ExprList> idMapping, ExprListEval exprListEval, Supplier<org.apache.jena.graph.Graph> graphSupplier)
    Util function to yield a mapper from tables to graphs based on the provided arguments.
    static org.apache.jena.graph.Node
    defaultEvalToNode(org.apache.jena.sparql.expr.ExprList exprs, org.apache.jena.sparql.engine.binding.Binding binding)
    One of the many ways to create always the same node (equals) from the values obtained by evaluating a list of expressions w.r.t.
    static io.reactivex.rxjava3.core.Flowable<org.apache.jena.rdf.model.RDFNode>
    execConstructEntities(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryBasic queryEx, Supplier<org.apache.jena.graph.Graph> graphSupplier, ExprListEval exprListEval)
    Execute a CONSTRUCT query w.r.t.
    static io.reactivex.rxjava3.core.Flowable<org.apache.jena.sparql.core.Quad>
    execConstructEntitiesNg(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryBasic queryEx)
     
    static io.reactivex.rxjava3.core.Flowable<org.apache.jena.sparql.core.Quad>
    execConstructEntitiesNg(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryBasic queryEx, Supplier<org.apache.jena.graph.Graph> graphSupplier, ExprListEval exprListEval)
    Stream the result of an entity query as named graphs
    static io.reactivex.rxjava3.core.Flowable<org.apache.jena.sparql.core.Quad>
    execConstructEntitiesNg(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryImpl query)
     
    static io.reactivex.rxjava3.core.Flowable<org.apache.jena.sparql.core.Quad>
    execConstructEntitiesNg(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryImpl query, Supplier<org.apache.jena.graph.Graph> graphSupplier)
     
    static io.reactivex.rxjava3.core.Flowable<org.apache.jena.sparql.core.Quad>
    execConstructEntitiesNg(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryImpl queryEx, Supplier<org.apache.jena.graph.Graph> graphSupplier, ExprListEval exprListEval)
     
    static io.reactivex.rxjava3.core.Flowable<GraphPartitionWithEntities>
    execConstructPartitionedOld(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryBasic queryEx, Supplier<org.apache.jena.graph.Graph> graphSupplier, ExprListEval exprListEval)
     
    static io.reactivex.rxjava3.core.Flowable<GraphPartitionWithEntities>
    execConstructPartitionedOld(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryImpl queryEx, Supplier<org.apache.jena.graph.Graph> graphSupplier, ExprListEval exprListEval)
     
    static io.reactivex.rxjava3.core.Flowable<org.apache.jena.rdf.model.RDFNode>
    execConstructRooted(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryBasic query)
    Execute a partitioned query.
    static io.reactivex.rxjava3.core.Flowable<org.apache.jena.rdf.model.RDFNode>
    execConstructRooted(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryBasic query, Supplier<org.apache.jena.graph.Graph> graphSupplier)
    Execute a partitioned query.
    static io.reactivex.rxjava3.core.Flowable<GraphPartitionWithEntities>
    execQueryActual(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, List<org.apache.jena.sparql.core.Var> partitionVars, Set<org.apache.jena.graph.Node> trackedTemplateNodes, org.apache.jena.query.Query selectQuery, Function<org.apache.jena.sparql.algebra.Table,AggObjectGraph.AccObjectGraph> tableToGraph)
     
    static io.reactivex.rxjava3.core.Flowable<Map.Entry<org.apache.jena.sparql.engine.binding.Binding,org.apache.jena.sparql.algebra.Table>>
    execSelectPartitioned(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, org.apache.jena.query.Query selectQuery, List<org.apache.jena.sparql.core.Var> partitionVars)
    Execute a SPARQL select query and partition its result set by the given partition variables.
    static List<org.apache.jena.sparql.core.Var>
    getEntityVars(org.apache.jena.graph.Node root, Map<org.apache.jena.graph.Node,org.apache.jena.sparql.expr.ExprList> idMapping)
     
    static Set<org.apache.jena.sparql.core.Var>
    getEssentialProjectVars(org.apache.jena.sparql.syntax.Template template, Map<org.apache.jena.graph.Node,org.apache.jena.sparql.expr.ExprList> idMapping)
    Return the sets of variables used in the template and the id mapping.
    merge(String groupName, List<org.apache.jena.sparql.core.Var> partitionVars, Collection<? extends GraphPartitionJoin> gps, boolean isOptional)
     
    Merges all graph partitions with the same fetch group name into a single graph partition.
    static org.apache.jena.query.Query
    prependToOrderBy(org.apache.jena.query.Query query, List<org.apache.jena.query.SortCondition> sortConditions)
    Prepend a given sequence of sort conditions to those already in the query (if there are already any).
    static org.apache.jena.query.Query
    preprocessQueryForPartitionWithoutSubSelect(org.apache.jena.query.Query baseQuery, List<org.apache.jena.sparql.core.Var> partitionVars, Set<org.apache.jena.sparql.core.Var> requiredVars, boolean sortRowsByPartitionVars)
    Return a SELECT query from the given query where - it is ensured that all partitionVars are part of the projection (if they aren't already) - distinct is applied in preparation to instantiation of construct templates (where duplicates can be ignored) - if sortRowsByPartitionVar is true then result bindings are sorted by the primary key vars so that bindings that belong together are consecutive - In case of a construct template without variables variable free is handled
    static org.apache.jena.query.Query
    preprocessQueryForPartitionWithSubSelect(org.apache.jena.query.Query entityQuery, List<org.apache.jena.sparql.core.Var> partitionVars, org.apache.jena.sparql.syntax.Element attributeElement, Set<org.apache.jena.sparql.core.Var> requiredVars, List<org.apache.jena.query.SortCondition> partitionOrderBy, org.aksw.commons.collections.generator.Generator<org.apache.jena.sparql.core.Var> varGenerator)
     
    processEntityQuery(EntityQueryBasic queryEx, boolean forceSubSelect)
     
    processEntityQuery(EntityQueryBasic queryEx, boolean forceSubSelect, Supplier<org.apache.jena.graph.Graph> graphSupplier, ExprListEval exprListEval)
    Execute a CONSTRUCT query using partitions.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EntityQueryRx

      public EntityQueryRx()
  • Method Details

    • execConstructEntitiesNg

      public static io.reactivex.rxjava3.core.Flowable<org.apache.jena.sparql.core.Quad> execConstructEntitiesNg(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryImpl query)
    • execConstructEntitiesNg

      public static io.reactivex.rxjava3.core.Flowable<org.apache.jena.sparql.core.Quad> execConstructEntitiesNg(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryImpl query, Supplier<org.apache.jena.graph.Graph> graphSupplier)
    • execConstructEntitiesNg

      public static io.reactivex.rxjava3.core.Flowable<org.apache.jena.sparql.core.Quad> execConstructEntitiesNg(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryImpl queryEx, Supplier<org.apache.jena.graph.Graph> graphSupplier, ExprListEval exprListEval)
    • execConstructRooted

      public static io.reactivex.rxjava3.core.Flowable<org.apache.jena.rdf.model.RDFNode> execConstructRooted(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryBasic query)
      Execute a partitioned query. See
      invalid reference
      #execConstructEntities(SparqlQueryConnection, EntityQueryBasic, Supplier, ExprListEval)
    • execConstructRooted

      public static io.reactivex.rxjava3.core.Flowable<org.apache.jena.rdf.model.RDFNode> execConstructRooted(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryBasic query, Supplier<org.apache.jena.graph.Graph> graphSupplier)
      Execute a partitioned query. See
      invalid reference
      #execConstructEntities(SparqlQueryConnection, EntityQueryBasic, Supplier, ExprListEval)
    • alignVariables

      public static EntityQueryImpl alignVariables(EntityQueryImpl query)
      Create a transformed copy of the query where all variables that need to join have the same name whereas variables that are not supposed to join have been remapped
      Parameters:
      query -
      Returns:
    • assembleEntityAndAttributeParts

      public static EntityQueryBasic assembleEntityAndAttributeParts(EntityQueryImpl queryRaw)
    • mergeFetchGroups

      public static EntityQueryImpl mergeFetchGroups(EntityQueryImpl query)
      Merges all graph partitions with the same fetch group name into a single graph partition.
      Parameters:
      queryRaw -
      Returns:
    • merge

      public static GraphPartitionJoin merge(String groupName, List<org.apache.jena.sparql.core.Var> partitionVars, Collection<? extends GraphPartitionJoin> gps, boolean isOptional)
    • execSelectPartitioned

      public static io.reactivex.rxjava3.core.Flowable<Map.Entry<org.apache.jena.sparql.engine.binding.Binding,org.apache.jena.sparql.algebra.Table>> execSelectPartitioned(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, org.apache.jena.query.Query selectQuery, List<org.apache.jena.sparql.core.Var> partitionVars)
      Execute a SPARQL select query and partition its result set by the given partition variables.
      Parameters:
      conn -
      selectQuery -
      partitionVars -
      Returns:
    • execConstructPartitionedOld

      public static io.reactivex.rxjava3.core.Flowable<GraphPartitionWithEntities> execConstructPartitionedOld(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryImpl queryEx, Supplier<org.apache.jena.graph.Graph> graphSupplier, ExprListEval exprListEval)
    • execConstructPartitionedOld

      public static io.reactivex.rxjava3.core.Flowable<GraphPartitionWithEntities> execConstructPartitionedOld(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryBasic queryEx, Supplier<org.apache.jena.graph.Graph> graphSupplier, ExprListEval exprListEval)
    • processEntityQuery

      public static EntityQueryRx.EntityQueryProcessed processEntityQuery(EntityQueryBasic queryEx, boolean forceSubSelect)
    • processEntityQuery

      public static EntityQueryRx.EntityQueryProcessed processEntityQuery(EntityQueryBasic queryEx, boolean forceSubSelect, Supplier<org.apache.jena.graph.Graph> graphSupplier, ExprListEval exprListEval)
      Execute a CONSTRUCT query using partitions.
      Parameters:
      queryEx -
      graphSupplier -
      exprListEval -
      conn -
      Returns:
    • execQueryActual

      public static io.reactivex.rxjava3.core.Flowable<GraphPartitionWithEntities> execQueryActual(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, List<org.apache.jena.sparql.core.Var> partitionVars, Set<org.apache.jena.graph.Node> trackedTemplateNodes, org.apache.jena.query.Query selectQuery, Function<org.apache.jena.sparql.algebra.Table,AggObjectGraph.AccObjectGraph> tableToGraph)
    • execConstructEntities

      public static io.reactivex.rxjava3.core.Flowable<org.apache.jena.rdf.model.RDFNode> execConstructEntities(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryBasic queryEx, Supplier<org.apache.jena.graph.Graph> graphSupplier, ExprListEval exprListEval)
      Execute a CONSTRUCT query w.r.t. partitions. For every partition a graph fragment is constructed based on bindings that fell into the partition. In addition, designate all values in that partition that were bound to the node referred to by
      invalid reference
      EntityQueryBasic#getEntityNode()
      as 'roots' of that partition. Roots serve as designated starting points for traversal of the graph fragment. Each root is returned as as separate RDFNode instance that holds a reference to that partition's graph.
      Parameters:
      conn -
      queryEx -
      graphSupplier -
      exprListEval -
      Returns:
    • execConstructEntitiesNg

      public static io.reactivex.rxjava3.core.Flowable<org.apache.jena.sparql.core.Quad> execConstructEntitiesNg(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryBasic queryEx)
    • execConstructEntitiesNg

      public static io.reactivex.rxjava3.core.Flowable<org.apache.jena.sparql.core.Quad> execConstructEntitiesNg(org.aksw.jenax.dataaccess.sparql.factory.execution.query.QueryExecutionFactoryQuery conn, EntityQueryBasic queryEx, Supplier<org.apache.jena.graph.Graph> graphSupplier, ExprListEval exprListEval)
      Stream the result of an entity query as named graphs
      Returns:
    • createTableToGraphMapper

      public static Function<org.apache.jena.sparql.algebra.Table,AggObjectGraph.AccObjectGraph> createTableToGraphMapper(org.apache.jena.sparql.syntax.Template template, Set<? extends org.apache.jena.graph.Node> trackedTemplateNodes, Map<org.apache.jena.graph.Node,org.apache.jena.sparql.expr.ExprList> idMapping, ExprListEval exprListEval, Supplier<org.apache.jena.graph.Graph> graphSupplier)
      Util function to yield a mapper from tables to graphs based on the provided arguments.
    • createKeyFunction

      public static Function<org.apache.jena.sparql.engine.binding.Binding,org.apache.jena.graph.Node> createKeyFunction(org.apache.jena.graph.Node root, Map<org.apache.jena.graph.Node,org.apache.jena.sparql.expr.ExprList> idMapping, ExprListEval exprListEval)
      Based on the information present in EntityQueryBasic return a function that deterministically yields the same node (possibly a blank node) when passing equivalent bindings to it.
      Parameters:
      root -
      idMapping -
      exprListEval -
      Returns:
    • getEntityVars

      public static List<org.apache.jena.sparql.core.Var> getEntityVars(org.apache.jena.graph.Node root, Map<org.apache.jena.graph.Node,org.apache.jena.sparql.expr.ExprList> idMapping)
    • createGraphAggregator

      public static AggObjectGraph createGraphAggregator(org.apache.jena.sparql.syntax.Template template, Set<? extends org.apache.jena.graph.Node> trackedTemplateNodes, Map<org.apache.jena.graph.Node,org.apache.jena.sparql.expr.ExprList> idMap, ExprListEval exprListEval, Supplier<org.apache.jena.graph.Graph> graphSupplier)
      Create an aggregator whose accumulators accumulate graphs from Bindings w.r.t. to the provided mapping information.
      Parameters:
      template -
      idMap -
      exprListEval -
      graphSupplier -
      Returns:
    • defaultEvalToNode

      public static org.apache.jena.graph.Node defaultEvalToNode(org.apache.jena.sparql.expr.ExprList exprs, org.apache.jena.sparql.engine.binding.Binding binding)
      One of the many ways to create always the same node (equals) from the values obtained by evaluating a list of expressions w.r.t. a given binding.
      Parameters:
      exprs -
      binding -
      Returns:
    • aggregateConsecutiveItemsWithSameKey

      public static <ITEM, KEY, VALUE> io.reactivex.rxjava3.core.FlowableTransformer<ITEM,Map.Entry<KEY,VALUE>> aggregateConsecutiveItemsWithSameKey(Function<? super ITEM,KEY> itemToKey, org.aksw.commons.collector.domain.Aggregator<? super ITEM,?,VALUE> aggregator)
      A generic flowable transformer that groups consecutive items that evaluate to the same key. For every group an accumulator is created that receives the items.
      Type Parameters:
      ITEM - The incoming item type
      KEY - The type of the keys derived from the items
      VALUE - The type of the value accumulated from the items
      Parameters:
      itemToKey - A function that yiels an item's key
      aggregator - An aggregator for computing a value from the set of items with the same key
      Returns:
    • getEssentialProjectVars

      public static Set<org.apache.jena.sparql.core.Var> getEssentialProjectVars(org.apache.jena.sparql.syntax.Template template, Map<org.apache.jena.graph.Node,org.apache.jena.sparql.expr.ExprList> idMapping)
      Return the sets of variables used in the template and the id mapping.
      Parameters:
      objectQuery -
      Returns:
    • prependToOrderBy

      public static org.apache.jena.query.Query prependToOrderBy(org.apache.jena.query.Query query, List<org.apache.jena.query.SortCondition> sortConditions)
      Prepend a given sequence of sort conditions to those already in the query (if there are already any). Duplicate sort conditions are removed in the process
      Parameters:
      query -
      sortConditions - The sort conditions. If null or empty this method becomes a no-op.
      Returns:
      The input query
    • createSortConditionsFromExprs

      public static List<org.apache.jena.query.SortCondition> createSortConditionsFromExprs(Iterable<org.apache.jena.sparql.expr.Expr> exprs, int dir)
      Create sort conditions with the given directions from an iterable of Exprs
    • createSortConditionsFromVars

      public static List<org.apache.jena.query.SortCondition> createSortConditionsFromVars(Iterable<org.apache.jena.sparql.core.Var> vars, int dir)
      Util function to create sort conditions from variables and a direction
    • preprocessQueryForPartitionWithSubSelect

      public static org.apache.jena.query.Query preprocessQueryForPartitionWithSubSelect(org.apache.jena.query.Query entityQuery, List<org.apache.jena.sparql.core.Var> partitionVars, org.apache.jena.sparql.syntax.Element attributeElement, Set<org.apache.jena.sparql.core.Var> requiredVars, List<org.apache.jena.query.SortCondition> partitionOrderBy, org.aksw.commons.collections.generator.Generator<org.apache.jena.sparql.core.Var> varGenerator)
    • preprocessQueryForPartitionWithoutSubSelect

      public static org.apache.jena.query.Query preprocessQueryForPartitionWithoutSubSelect(org.apache.jena.query.Query baseQuery, List<org.apache.jena.sparql.core.Var> partitionVars, Set<org.apache.jena.sparql.core.Var> requiredVars, boolean sortRowsByPartitionVars)
      Return a SELECT query from the given query where - it is ensured that all partitionVars are part of the projection (if they aren't already) - distinct is applied in preparation to instantiation of construct templates (where duplicates can be ignored) - if sortRowsByPartitionVar is true then result bindings are sorted by the primary key vars so that bindings that belong together are consecutive - In case of a construct template without variables variable free is handled
      Parameters:
      baseQuery -
      partitionVars -
      requiredVars - The variables that need to be projected in the resulting query
      sortRowsByPartitionVar -
      Returns: