Search in sources :

Example 56 with QueryIterator

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

the class EvaluatorSimple method diffWorker.

// @@ Abstract compatibility
private Table diffWorker(Table tableLeft, Table tableRight) {
    QueryIterator left = tableLeft.iterator(execCxt);
    TableN r = new TableN();
    for (; left.hasNext(); ) {
        Binding b = left.nextBinding();
        if (tableRight.contains(b))
            r.addBinding(b);
    }
    tableLeft.close();
    tableRight.close();
    return r;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) QueryIterator(org.apache.jena.sparql.engine.QueryIterator) TableN(org.apache.jena.sparql.algebra.table.TableN)

Example 57 with QueryIterator

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

the class EvaluatorSimple method joinWorker.

private Table joinWorker(Table tableLeft, Table tableRight, boolean leftJoin, ExprList conditions) {
    QueryIterator left = tableLeft.iterator(execCxt);
    JoinType joinType = (leftJoin ? JoinType.LEFT : JoinType.INNER);
    QueryIterator qIter = TableJoin.joinWorker(left, tableRight, joinType, conditions, execCxt);
    tableLeft.close();
    tableRight.close();
    // qIter and left should be properly closed by use or called code. 
    return new TableN(qIter);
}
Also used : QueryIterator(org.apache.jena.sparql.engine.QueryIterator) TableN(org.apache.jena.sparql.algebra.table.TableN)

Example 58 with QueryIterator

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

the class EvaluatorSimple method procedure.

@Override
public Table procedure(Table table, Node procId, ExprList args) {
    Procedure proc = ProcEval.build(procId, args, execCxt);
    QueryIterator qIter = ProcEval.eval(table.iterator(execCxt), proc, execCxt);
    return TableFactory.create(qIter);
}
Also used : QueryIterator(org.apache.jena.sparql.engine.QueryIterator) Procedure(org.apache.jena.sparql.procedure.Procedure)

Example 59 with QueryIterator

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

the class BuilderResultSet method build.

public static ResultSet build(Item item) {
    BuilderLib.checkTagged(item, Tags.tagResultSet, "Not a (resultset ...)");
    ItemList list = item.getList();
    List<Var> vars = BuilderNode.buildVarList(list.get(1));
    // skip tag, skip vars.
    int start = 2;
    List<Binding> bindings = new ArrayList<>();
    for (int i = start; i < list.size(); i++) {
        Item itemRow = list.get(i);
        Binding b = BuilderBinding.build(itemRow);
        bindings.add(b);
    }
    QueryIterator qIter = new QueryIterPlainWrapper(bindings.listIterator());
    return new ResultSetStream(Var.varNames(vars), null, qIter);
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) Item(org.apache.jena.sparql.sse.Item) QueryIterPlainWrapper(org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper) QueryIterator(org.apache.jena.sparql.engine.QueryIterator) Var(org.apache.jena.sparql.core.Var) ItemList(org.apache.jena.sparql.sse.ItemList) ArrayList(java.util.ArrayList) ResultSetStream(org.apache.jena.sparql.engine.ResultSetStream)

Example 60 with QueryIterator

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

the class WriterTable method outputPlain.

public static void outputPlain(IndentedWriter out, Table table, SerializationContext sCxt) {
    QueryIterator qIter = table.iterator(null);
    for (; qIter.hasNext(); ) {
        Binding b = qIter.nextBinding();
        output(out, b, sCxt);
        out.println();
    }
    qIter.close();
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) QueryIterator(org.apache.jena.sparql.engine.QueryIterator)

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