Search in sources :

Example 1 with ReorderProc

use of org.apache.jena.sparql.engine.optimizer.reorder.ReorderProc in project jena by apache.

the class StageGeneratorGeneric method execute.

protected QueryIterator execute(BasicPattern pattern, ReorderTransformation reorder, StageGenerator execution, QueryIterator input, ExecutionContext execCxt) {
    Explain.explain(pattern, execCxt.getContext());
    if (!input.hasNext())
        return input;
    if (reorder != null && pattern.size() >= 2) {
        // If pattern size is 0 or 1, nothing to do.
        BasicPattern bgp2 = pattern;
        // Try to ground the pattern
        if (!input.isJoinIdentity()) {
            QueryIterPeek peek = QueryIterPeek.create(input, execCxt);
            // And now use this one
            input = peek;
            Binding b = peek.peek();
            bgp2 = Substitute.substitute(pattern, b);
            ReorderProc reorderProc = reorder.reorderIndexes(bgp2);
            pattern = reorderProc.reorder(pattern);
        }
    }
    Explain.explain("Reorder/generic", pattern, execCxt.getContext());
    return QueryIterBlockTriples.create(input, pattern, execCxt);
}
Also used : QueryIterPeek(org.apache.jena.sparql.engine.iterator.QueryIterPeek) Binding(org.apache.jena.sparql.engine.binding.Binding) ReorderProc(org.apache.jena.sparql.engine.optimizer.reorder.ReorderProc) BasicPattern(org.apache.jena.sparql.core.BasicPattern)

Example 2 with ReorderProc

use of org.apache.jena.sparql.engine.optimizer.reorder.ReorderProc in project jena by apache.

the class OpExecutorTDB1 method reorder.

private static BasicPattern reorder(BasicPattern pattern, QueryIterPeek peek, ReorderTransformation transform) {
    if (transform != null) {
        if (!peek.hasNext())
            throw new ARQInternalErrorException("Peek iterator is already empty");
        BasicPattern pattern2 = Substitute.substitute(pattern, peek.peek());
        // Calculate the reordering based on the substituted pattern.
        ReorderProc proc = transform.reorderIndexes(pattern2);
        // Then reorder original patten
        pattern = proc.reorder(pattern);
    }
    return pattern;
}
Also used : ReorderProc(org.apache.jena.sparql.engine.optimizer.reorder.ReorderProc) ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException) BasicPattern(org.apache.jena.sparql.core.BasicPattern)

Aggregations

BasicPattern (org.apache.jena.sparql.core.BasicPattern)2 ReorderProc (org.apache.jena.sparql.engine.optimizer.reorder.ReorderProc)2 ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)1 Binding (org.apache.jena.sparql.engine.binding.Binding)1 QueryIterPeek (org.apache.jena.sparql.engine.iterator.QueryIterPeek)1