Search in sources :

Example 11 with Op

use of org.apache.jena.sparql.algebra.Op in project jena by apache.

the class ApplyTransformVisitor method visit.

@Override
public void visit(OpFilter opFilter) {
    Op subOp = null;
    if (opFilter.getSubOp() != null)
        subOp = pop(opStack);
    ExprList ex = opFilter.getExprs();
    if (ex == null || ex.isEmpty()) {
        // No expressions.
        // Doesn't normally happen but this code is safe in these cases.
        push(opStack, opFilter.apply(opTransform, subOp));
        return;
    }
    // ex2 is the same length as ex. 
    ExprList ex2 = collect(ex);
    OpFilter f = opFilter;
    if (ex != ex2 || opFilter.getSubOp() != subOp) {
        f = OpFilter.filterAlways(ex2, subOp);
        // If we removed a layer of filter, then subOp needs changing
        // else f-subOp is subOp anyway.    
        subOp = f.getSubOp();
    }
    push(opStack, f.apply(opTransform, subOp));
}
Also used : Op(org.apache.jena.sparql.algebra.Op) VarExprList(org.apache.jena.sparql.core.VarExprList)

Example 12 with Op

use of org.apache.jena.sparql.algebra.Op in project jena by apache.

the class ApplyTransformVisitor method visit.

@Override
public void visit(ExprFunctionOp funcOp) {
    ExprList x = null;
    if (funcOp.getArgs() != null)
        x = collect(funcOp.getArgs());
    Op op = pop(opStack);
    Expr e = funcOp.apply(exprTransform, x, op);
    push(exprStack, e);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) VarExprList(org.apache.jena.sparql.core.VarExprList)

Example 13 with Op

use of org.apache.jena.sparql.algebra.Op in project jena by apache.

the class ApplyTransformVisitor method visit2.

@Override
public void visit2(Op2 op) {
    Op left = null;
    Op right = null;
    // Must do right-left because the pushes onto the stack were left-right.
    if (op.getRight() != null)
        right = pop(opStack);
    if (op.getLeft() != null)
        left = pop(opStack);
    Op opX = op.apply(opTransform, left, right);
    push(opStack, opX);
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 14 with Op

use of org.apache.jena.sparql.algebra.Op in project jena by apache.

the class WalkerVisitor method visitN.

@Override
public void visitN(OpN op) {
    before(op);
    for (Iterator<Op> iter = op.iterator(); iter.hasNext(); ) {
        Op sub = iter.next();
        sub.visit(this);
    }
    if (opVisitor != null)
        op.visit(opVisitor);
    after(op);
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 15 with Op

use of org.apache.jena.sparql.algebra.Op in project jena by apache.

the class GraphSPARQLService method graphBaseFind.

//    @Override
//    public Capabilities getCapabilities()
//    { 
//    	if (capabilities == null)
//            capabilities = new AllCapabilities()
//        	  { @Override public boolean handlesLiteralTyping() { return false; } };
//        return capabilities;
//    }
@Override
protected ExtendedIterator<Triple> graphBaseFind(Triple m) {
    Node s = m.getMatchSubject();
    Var sVar = null;
    if (s == null) {
        sVar = Var.alloc("s");
        s = sVar;
    }
    Node p = m.getMatchPredicate();
    Var pVar = null;
    if (p == null) {
        pVar = Var.alloc("p");
        p = pVar;
    }
    Node o = m.getMatchObject();
    Var oVar = null;
    if (o == null) {
        oVar = Var.alloc("o");
        o = oVar;
    }
    Triple triple = new Triple(s, p, o);
    // Evaluate as an algebra expression
    BasicPattern pattern = new BasicPattern();
    pattern.add(triple);
    Op op = new OpBGP(pattern);
    //        return WrappedIterator.createNoRemove(triples.iterator()) ;
    return null;
}
Also used : Triple(org.apache.jena.graph.Triple) Op(org.apache.jena.sparql.algebra.Op) Var(org.apache.jena.sparql.core.Var) Node(org.apache.jena.graph.Node) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) BasicPattern(org.apache.jena.sparql.core.BasicPattern)

Aggregations

Op (org.apache.jena.sparql.algebra.Op)166 Var (org.apache.jena.sparql.core.Var)29 VarExprList (org.apache.jena.sparql.core.VarExprList)18 Query (org.apache.jena.query.Query)17 ExprList (org.apache.jena.sparql.expr.ExprList)17 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)15 Test (org.junit.Test)14 Triple (org.apache.jena.graph.Triple)13 Expr (org.apache.jena.sparql.expr.Expr)13 BasicPattern (org.apache.jena.sparql.core.BasicPattern)11 ArrayList (java.util.ArrayList)9 Node (org.apache.jena.graph.Node)8 OpBGP (org.apache.jena.sparql.algebra.op.OpBGP)7 NodeValueInteger (org.apache.jena.sparql.expr.nodevalue.NodeValueInteger)7 Binding (org.apache.jena.sparql.engine.binding.Binding)5 ExprVar (org.apache.jena.sparql.expr.ExprVar)5 BaseTest (org.apache.jena.atlas.junit.BaseTest)3 Pair (org.apache.jena.atlas.lib.Pair)3 Table (org.apache.jena.sparql.algebra.Table)3 TransformCopy (org.apache.jena.sparql.algebra.TransformCopy)3