Search in sources :

Example 51 with QueryIterator

use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.

the class OpExecutor method execute.

protected QueryIterator execute(OpProcedure opProc, QueryIterator input) {
    Procedure procedure = ProcEval.build(opProc, execCxt);
    QueryIterator qIter = exec(opProc.getSubOp(), input);
    // Delay until query starts executing.
    return new QueryIterProcedure(qIter, procedure, execCxt);
}
Also used : QueryIterator(org.apache.jena.sparql.engine.QueryIterator) Procedure(org.apache.jena.sparql.procedure.Procedure)

Example 52 with QueryIterator

use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.

the class QueryIterGraph method nextStage.

@Override
protected QueryIterator nextStage(Binding outerBinding) {
    DatasetGraph ds = getExecContext().getDataset();
    // Is this closed?
    Iterator<Node> graphNameNodes = makeSources(ds, outerBinding, opGraph.getNode());
    //        List<Node> x = Iter.toList(graphNameNodes) ;
    //        graphNameNodes = x.iterator() ;
    //        System.out.println(x) ;
    QueryIterator current = new QueryIterGraphInner(outerBinding, graphNameNodes, opGraph, getExecContext());
    return current;
}
Also used : QueryIterator(org.apache.jena.sparql.engine.QueryIterator) Node(org.apache.jena.graph.Node) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 53 with QueryIterator

use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.

the class QueryIterService method nextStage.

@Override
protected QueryIterator nextStage(Binding outerBinding) {
    Op op = QC.substitute(opService, outerBinding);
    boolean silent = opService.getSilent();
    QueryIterator qIter;
    try {
        qIter = Service.exec((OpService) op, getExecContext().getContext());
        // This iterator is materialized already otherwise we may end up
        // not servicing the HTTP connection as needed.
        // In extremis, can cause a deadlock when SERVICE loops back to this server.
        // Add tracking.
        qIter = QueryIter.makeTracked(qIter, getExecContext());
    } catch (RuntimeException ex) {
        if (silent) {
            Log.warn(this, "SERVICE <" + opService.getService().toString() + ">: " + ex.getMessage());
            // Return the input
            return QueryIterSingleton.create(outerBinding, getExecContext());
        }
        throw ex;
    }
    // Need to put the outerBinding as parent to every binding of the service call.
    // There should be no variables in common because of the OpSubstitute.substitute 
    QueryIterator qIter2 = new QueryIterCommonParent(qIter, outerBinding, getExecContext());
    return qIter2;
}
Also used : Op(org.apache.jena.sparql.algebra.Op) QueryIterator(org.apache.jena.sparql.engine.QueryIterator) QueryIterCommonParent(org.apache.jena.sparql.engine.iterator.QueryIterCommonParent) OpService(org.apache.jena.sparql.algebra.op.OpService)

Example 54 with QueryIterator

use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.

the class QueryIterUnion method nextStage.

@Override
protected QueryIterator nextStage(Binding binding) {
    QueryIterConcat unionQIter = new QueryIterConcat(getExecContext());
    for (Op subOp : subOps) {
        subOp = QC.substitute(subOp, binding);
        QueryIterator parent = QueryIterSingleton.create(binding, getExecContext());
        QueryIterator qIter = QC.execute(subOp, parent, getExecContext());
        unionQIter.add(qIter);
    }
    return unionQIter;
}
Also used : QueryIterConcat(org.apache.jena.sparql.engine.iterator.QueryIterConcat) Op(org.apache.jena.sparql.algebra.Op) QueryIterator(org.apache.jena.sparql.engine.QueryIterator)

Example 55 with QueryIterator

use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.

the class EvaluatorSimple method slice.

@Override
public Table slice(Table table, long start, long length) {
    QueryIterator qIter = table.iterator(getExecContext());
    qIter = new QueryIterSlice(qIter, start, length, getExecContext());
    return new TableN(qIter);
}
Also used : QueryIterator(org.apache.jena.sparql.engine.QueryIterator) TableN(org.apache.jena.sparql.algebra.table.TableN)

Aggregations

QueryIterator (org.apache.jena.sparql.engine.QueryIterator)126 Binding (org.apache.jena.sparql.engine.binding.Binding)27 Op (org.apache.jena.sparql.algebra.Op)15 Node (org.apache.jena.graph.Node)13 TableN (org.apache.jena.sparql.algebra.table.TableN)13 ArrayList (java.util.ArrayList)12 ResultSetStream (org.apache.jena.sparql.engine.ResultSetStream)10 Var (org.apache.jena.sparql.core.Var)9 ResultSet (org.apache.jena.query.ResultSet)8 QueryIterPlainWrapper (org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper)8 Triple (org.apache.jena.graph.Triple)6 ExecutionContext (org.apache.jena.sparql.engine.ExecutionContext)6 BasicPattern (org.apache.jena.sparql.core.BasicPattern)5 QueryIterConcat (org.apache.jena.sparql.engine.iterator.QueryIterConcat)5 Table (org.apache.jena.sparql.algebra.Table)4 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)4 HashSet (java.util.HashSet)3 Plan (org.apache.jena.sparql.engine.Plan)3 BindingMap (org.apache.jena.sparql.engine.binding.BindingMap)3 Procedure (org.apache.jena.sparql.procedure.Procedure)3