use of org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation in project jena by apache.
the class StageGeneratorGeneric method execute.
@Override
public QueryIterator execute(BasicPattern pattern, QueryIterator input, ExecutionContext execCxt) {
if (input == null)
Log.error(this, "Null input to " + Lib.classShortName(this.getClass()));
Graph graph = execCxt.getActiveGraph();
// Choose reorder transformation and execution strategy.
ReorderTransformation reorder = reorderFixed;
StageGenerator executor = StageBuilder.executeInline;
return execute(pattern, reorder, executor, input, execCxt);
}
use of org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation in project jena by apache.
the class tdbreorder method main.
public static void main(String... args) {
if (args.length != 2) {
System.err.println("Usage: PATTERN STATS");
System.exit(1);
}
LogCtl.enable(StatsMatcher.class);
LogCtl.enable(ReorderTransformationSubstitution.class);
if (args.length != 2) {
System.err.println("Usage: op stats");
System.exit(1);
}
String pattern = args[0];
String statsFile = args[1];
Op op = SSE.readOp(pattern);
BasicPattern bgp;
if (op instanceof OpQuadPattern) {
bgp = ((OpQuadPattern) op).getBasicPattern();
} else if (op instanceof OpBGP) {
bgp = ((OpBGP) op).getPattern();
} else {
System.err.println("Not a quad or triple pattern");
System.exit(2);
bgp = null;
}
ReorderTransformation reorder = chooseReorder(statsFile);
// ReorderTransformation reorder = ReorderLib.fixed() ;
BasicPattern bgp2 = reorder.reorder(bgp);
System.out.println();
print(bgp);
System.out.println();
System.out.println(" ======== >>>>>>>>");
print(bgp2);
System.out.println();
}
use of org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation in project jena by apache.
the class OpExecutorTDB2 method optimizeExecuteQuads.
/**
* Execute, with optimization, a quad pattern
*/
private static QueryIterator optimizeExecuteQuads(DatasetGraphTDB dsgtdb, QueryIterator input, Node gn, BasicPattern bgp, ExprList exprs, ExecutionContext execCxt) {
if (!input.hasNext())
return input;
// ---- Graph names with special meaning.
gn = decideGraphNode(gn, execCxt);
if (gn == null)
return optimizeExecuteTriples(dsgtdb, input, bgp, exprs, execCxt);
// ---- Execute quads+filters
if (bgp.size() >= 2) {
ReorderTransformation transform = dsgtdb.getReorderTransform();
if (transform != null) {
QueryIterPeek peek = QueryIterPeek.create(input, execCxt);
// Original input now invalid.
input = peek;
bgp = reorder(bgp, peek, transform);
}
}
if (exprs == null) {
// Triple-backed (but may be named as explicit default graph).
Explain.explain("Execute", bgp, execCxt.getContext());
Predicate<Tuple<NodeId>> filter = QC2.getFilter(execCxt.getContext());
return PatternMatchTDB2.execute(dsgtdb, gn, bgp, input, filter, execCxt);
}
// -- Filter placement
Op op = TransformFilterPlacement.transform(exprs, gn, bgp);
return plainExecute(op, input, execCxt);
}
use of org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation in project jena by apache.
the class OpExecutorTDB2 method optimizeExecuteTriples.
/**
* Execute, with optimization, a basic graph pattern on the default graph storage
*/
private static QueryIterator optimizeExecuteTriples(DatasetGraphTDB dsgtdb, QueryIterator input, BasicPattern pattern, ExprList exprs, ExecutionContext execCxt) {
if (!input.hasNext())
return input;
// Must pass this iterator into the next stage.
if (pattern.size() >= 2) {
// Must be 2 or triples to reorder.
ReorderTransformation transform = dsgtdb.getReorderTransform();
if (transform != null) {
QueryIterPeek peek = QueryIterPeek.create(input, execCxt);
// Must pass on
input = peek;
pattern = reorder(pattern, peek, transform);
}
}
if (exprs == null) {
Explain.explain("Execute", pattern, execCxt.getContext());
Predicate<Tuple<NodeId>> filter = QC2.getFilter(execCxt.getContext());
return PatternMatchTDB2.execute(dsgtdb, Quad.defaultGraphNodeGenerated, pattern, input, filter, execCxt);
}
// -- Filter placement
Op op = TransformFilterPlacement.transform(exprs, pattern);
return plainExecute(op, input, execCxt);
}
use of org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation in project jena by apache.
the class OpExecutorTDB1 method optimizeExecuteTriples.
/**
* Execute, with optimization, a basic graph pattern on the default graph storage
*/
private static QueryIterator optimizeExecuteTriples(DatasetGraphTDB dsgtdb, QueryIterator input, BasicPattern pattern, ExprList exprs, ExecutionContext execCxt) {
if (!input.hasNext())
return input;
// Must pass this iterator into the next stage.
if (pattern.size() >= 2) {
// Must be 2 or triples to reorder.
ReorderTransformation transform = dsgtdb.getReorderTransform();
if (transform != null) {
QueryIterPeek peek = QueryIterPeek.create(input, execCxt);
// Must pass on
input = peek;
pattern = reorder(pattern, peek, transform);
}
}
if (exprs == null) {
Explain.explain("Execute", pattern, execCxt.getContext());
Predicate<Tuple<NodeId>> filter = QC2.getFilter(execCxt.getContext());
return PatternMatchTDB1.execute(dsgtdb, Quad.defaultGraphNodeGenerated, pattern, input, filter, execCxt);
}
// -- Filter placement
Op op = TransformFilterPlacement.transform(exprs, pattern);
return plainExecute(op, input, execCxt);
}
Aggregations