Search in sources :

Example 46 with QueryIterator

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

the class EvaluatorSimple method groupBy.

@Override
public Table groupBy(Table table, VarExprList groupVars, List<ExprAggregator> aggregators) {
    QueryIterator qIter = table.iterator(getExecContext());
    qIter = new QueryIterGroup(qIter, groupVars, aggregators, getExecContext());
    return new TableN(qIter);
}
Also used : QueryIterator(org.apache.jena.sparql.engine.QueryIterator) TableN(org.apache.jena.sparql.algebra.table.TableN)

Example 47 with QueryIterator

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

the class EvaluatorSimple method filter.

@Override
public Table filter(ExprList expressions, Table table) {
    if (debug) {
        System.out.println("Restriction");
        System.out.println(expressions);
        dump(table);
    }
    QueryIterator iter = table.iterator(execCxt);
    List<Binding> output = new ArrayList<>();
    for (; iter.hasNext(); ) {
        Binding b = iter.nextBinding();
        if (expressions.isSatisfied(b, execCxt))
            output.add(b);
    }
    return new TableN(new QueryIterPlainWrapper(output.iterator(), execCxt));
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) QueryIterator(org.apache.jena.sparql.engine.QueryIterator) ArrayList(java.util.ArrayList) TableN(org.apache.jena.sparql.algebra.table.TableN)

Example 48 with QueryIterator

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

the class EvaluatorSimple method minusWorker.

private Table minusWorker(Table tableLeft, Table tableRight) {
    // Minus(Ω1, Ω2) = { μ | μ in Ω1 such that for all μ' in Ω2, either μ and μ' are not compatible or dom(μ) and dom(μ') are disjoint }
    TableN results = new TableN();
    QueryIterator iterLeft = tableLeft.iterator(execCxt);
    for (; iterLeft.hasNext(); ) {
        Binding bindingLeft = iterLeft.nextBinding();
        boolean includeThisRow = true;
        // Find a reason not to include the row.
        // That's is not disjoint and not compatible.
        QueryIterator iterRight = tableRight.iterator(execCxt);
        for (; iterRight.hasNext(); ) {
            Binding bindingRight = iterRight.nextBinding();
            if (Algebra.disjoint(bindingLeft, bindingRight))
                // Disjoint - not a reason to exclude
                continue;
            if (!Algebra.compatible(bindingLeft, bindingRight))
                // Compatible - not a reason to exclude.
                continue;
            includeThisRow = false;
            break;
        }
        iterRight.close();
        if (includeThisRow)
            results.addBinding(bindingLeft);
    }
    iterLeft.close();
    return results;
}
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 49 with QueryIterator

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

the class OpExecutor method execute.

protected QueryIterator execute(OpGroup opGroup, QueryIterator input) {
    QueryIterator qIter = exec(opGroup.getSubOp(), input);
    qIter = new QueryIterGroup(qIter, opGroup.getGroupVars(), opGroup.getAggregators(), execCxt);
    return qIter;
}
Also used : QueryIterator(org.apache.jena.sparql.engine.QueryIterator)

Example 50 with QueryIterator

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

the class OpExecutor method execute.

protected QueryIterator execute(OpSlice opSlice, QueryIterator input) {
    QueryIterator qIter = exec(opSlice.getSubOp(), input);
    qIter = new QueryIterSlice(qIter, opSlice.getStart(), opSlice.getLength(), execCxt);
    return qIter;
}
Also used : 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