Search in sources :

Example 1 with QuadSlot

use of org.apache.jena.sparql.algebra.AlgebraQuad.QuadSlot in project jena by apache.

the class TransformQuadGraph method transform.

@Override
public Op transform(OpGraph opGraph, Op op) {
    //System.err.println("transform(OpGraph)\n"+opGraph+op) ;
    // ?? Could just leave the (graph) in place always - just rewrite BGPs. 
    boolean noPattern = false;
    /* One case to consider is when the pattern for the GRAPH
         * statement includes uses the variable inside the GRAPH clause. 
         * In this case, we must rename away the inner variable
         * to allow stream execution via index joins, 
         * and then put back the value via an assign.
         * (This is what QueryIterGraph does using a streaming join
         * for triples)
         */
    // Note: op is already quads by this point.
    // Must test scoping by the subOp of GRAPH
    QuadSlot qSlot = tracker.peek();
    Node actualName = qSlot.actualGraphName;
    Node rewriteName = qSlot.rewriteGraphName;
    if (OpBGP.isBGP(op)) {
        // Empty BGP
        if (((OpBGP) op).getPattern().isEmpty())
            noPattern = true;
    } else if (op instanceof OpTable) {
        // Empty BGP compiled to a unit table
        if (((OpTable) op).isJoinIdentity())
            noPattern = true;
    }
    if (noPattern) {
        // which are ways of accessing the names in the dataset.
        return new OpDatasetNames(opGraph.getNode());
    }
    if (actualName != rewriteName)
        op = OpAssign.assign(op, Var.alloc(actualName), new ExprVar(rewriteName));
    // have been converted to quads.
    return op;
}
Also used : ExprVar(org.apache.jena.sparql.expr.ExprVar) QuadSlot(org.apache.jena.sparql.algebra.AlgebraQuad.QuadSlot) Node(org.apache.jena.graph.Node)

Aggregations

Node (org.apache.jena.graph.Node)1 QuadSlot (org.apache.jena.sparql.algebra.AlgebraQuad.QuadSlot)1 ExprVar (org.apache.jena.sparql.expr.ExprVar)1