use of org.apache.jena.sparql.engine.ExecutionContext in project jena by apache.
the class SolverRX method find.
private static Iterator<BindingNodeId> find(BindingNodeId bnid, NodeTupleTable nodeTupleTable, Node xGraphNode, Triple xPattern, boolean anyGraph, Predicate<Tuple<NodeId>> filter, ExecutionContext execCxt) {
NodeTable nodeTable = nodeTupleTable.getNodeTable();
Binding input = bnid.isEmpty() ? BindingFactory.empty() : new BindingTDB(bnid, nodeTable);
Triple tPattern = Substitute.substitute(xPattern, input);
Node graphNode = Substitute.substitute(xGraphNode, input);
Node tGraphNode = anyGraph ? Quad.unionGraph : graphNode;
// graphNode is ANY for union graph and null for default graph.
// Var to ANY, Triple Term to ANY.
Node g = (graphNode == null) ? null : nodeTopLevel(graphNode);
Node s = nodeTopLevel(tPattern.getSubject());
Node p = nodeTopLevel(tPattern.getPredicate());
Node o = nodeTopLevel(tPattern.getObject());
Tuple<Node> patternTuple = (g == null) ? TupleFactory.create3(s, p, o) : TupleFactory.create4(g, s, p, o);
Iterator<Quad> dsgIter = accessData(patternTuple, nodeTupleTable, anyGraph, filter, execCxt);
Iterator<Binding> matched = Iter.iter(dsgIter).map(dQuad -> SolverRX4.matchQuad(input, dQuad, tGraphNode, tPattern)).removeNulls();
return convFromBinding(matched, nodeTable);
}
use of org.apache.jena.sparql.engine.ExecutionContext in project jena by apache.
the class OpExecutorTDB2 method plainExecute.
/**
* Execute without modification of the op - does <b>not</b> apply special graph name translations
*/
private static QueryIterator plainExecute(Op op, QueryIterator input, ExecutionContext execCxt) {
// -- Execute
// Switch to a non-reordering executor
// The Op may be a sequence due to TransformFilterPlacement
// so we need to do a full execution step, not go straight to the SolverLib.
ExecutionContext ec2 = new ExecutionContext(execCxt);
ec2.setExecutor(plainFactory);
// so there are no nested patterns to reorder.
return QC.execute(op, input, ec2);
}
use of org.apache.jena.sparql.engine.ExecutionContext in project jena by apache.
the class SpatialIndex method retrieve.
/**
* Retrieve the SpatialIndex from the Context.
*
* @param execCxt
* @return SpatialIndex contained in the Context.
* @throws SpatialIndexException
*/
public static final SpatialIndex retrieve(ExecutionContext execCxt) throws SpatialIndexException {
Context context = execCxt.getContext();
SpatialIndex spatialIndex = (SpatialIndex) context.get(SPATIAL_INDEX_SYMBOL, null);
if (spatialIndex == null) {
throw new SpatialIndexException("Dataset Context does not contain SpatialIndex.");
}
return spatialIndex;
}
use of org.apache.jena.sparql.engine.ExecutionContext in project jena by apache.
the class SolverRX method find.
private static Iterator<BindingNodeId> find(BindingNodeId bnid, NodeTupleTable nodeTupleTable, Node xGraphNode, Triple xPattern, boolean anyGraph, Predicate<Tuple<NodeId>> filter, ExecutionContext execCxt) {
NodeTable nodeTable = nodeTupleTable.getNodeTable();
Binding input = bnid.isEmpty() ? BindingFactory.empty() : new BindingTDB(bnid, nodeTable);
Triple tPattern = Substitute.substitute(xPattern, input);
Node graphNode = Substitute.substitute(xGraphNode, input);
Node tGraphNode = anyGraph ? Quad.unionGraph : graphNode;
// graphNode is ANY for union graph and null for default graph.
// Var to ANY, Triple Term to ANY.
Node g = (graphNode == null) ? null : nodeTopLevel(graphNode);
Node s = nodeTopLevel(tPattern.getSubject());
Node p = nodeTopLevel(tPattern.getPredicate());
Node o = nodeTopLevel(tPattern.getObject());
Tuple<Node> patternTuple = (g == null) ? TupleFactory.create3(s, p, o) : TupleFactory.create4(g, s, p, o);
Iterator<Quad> dsgIter = accessData(patternTuple, nodeTupleTable, anyGraph, filter, execCxt);
Iterator<Binding> matched = Iter.iter(dsgIter).map(dQuad -> SolverRX4.matchQuad(input, dQuad, tGraphNode, tPattern)).removeNulls();
return convFromBinding(matched, nodeTable);
}
use of org.apache.jena.sparql.engine.ExecutionContext in project jena by apache.
the class OpExecutorTDB1 method plainExecute.
/**
* Execute without modification of the op - does <b>not</b> apply special graph name translations
*/
private static QueryIterator plainExecute(Op op, QueryIterator input, ExecutionContext execCxt) {
// -- Execute
// Switch to a non-reordering executor
// The Op may be a sequence due to TransformFilterPlacement
// so we need to do a full execution step, not go straight to the SolverLib.
ExecutionContext ec2 = new ExecutionContext(execCxt);
ec2.setExecutor(plainFactory);
// so there are no nested patterns to reorder.
return QC.execute(op, input, ec2);
}
Aggregations