本文整理了Java中org.apache.jena.sparql.engine.ExecutionContext
类的一些代码示例,展示了ExecutionContext
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExecutionContext
类的具体详情如下:
包路径:org.apache.jena.sparql.engine.ExecutionContext
类名称:ExecutionContext
暂无
代码示例来源:origin: apache/jena
protected static QueryIterator buildIterator(Binding binding, Node graphNode, Op opExec, ExecutionContext outerCxt) {
if ( !graphNode.isURI() && !graphNode.isBlank() )
// e.g. variable bound to a literal or blank node.
throw new ARQInternalErrorException("QueryIterGraphInner.buildIterator: Not a URI or blank node: "+graphNode) ;
// We can't just use DatasetGraph.getGraph because it may
// "auto-create" graphs. Use the containsGraph function.
boolean syntheticGraph = ( Quad.isDefaultGraph(graphNode) || Quad.isUnionGraph(graphNode) ) ;
if ( ! syntheticGraph && ! outerCxt.getDataset().containsGraph(graphNode) )
return null ;
Graph g = outerCxt.getDataset().getGraph(graphNode) ;
// And the contains was true??!!!!!!
if ( g == null )
return null ;
//throw new ARQInternalErrorException(".containsGraph was true but .getGraph is null") ;
ExecutionContext cxt2 = new ExecutionContext(outerCxt, g) ;
QueryIterator subInput = QueryIterSingleton.create(binding, cxt2) ;
return QC.execute(opExec, subInput, cxt2) ;
}
代码示例来源:origin: apache/jena
public static QueryIterator execTriplePath(Binding binding, Node s, Path path, Node o, ExecutionContext execCxt) {
Explain.explain(s, path, o, execCxt.getContext()) ;
s = Var.lookup(binding, s) ;
o = Var.lookup(binding, o) ;
Iterator<Node> iter = null ;
Node endNode = null ;
Graph graph = execCxt.getActiveGraph() ;
// Both variables.
if ( Var.isVar(s) && Var.isVar(o) ) {
if ( s.equals(o) )
return execUngroundedPathSameVar(binding, graph, Var.alloc(s), path, execCxt);
else
return execUngroundedPath(binding, graph, Var.alloc(s), path, Var.alloc(o), execCxt);
}
// Both constants.
if ( !Var.isVar(s) && !Var.isVar(o) )
return evalGroundedPath(binding, graph, s, path, o, execCxt);
// One variable, one constant
if ( Var.isVar(s) ) {
// Var subject, concrete object - do backwards.
iter = PathEval.evalReverse(graph, o, path, execCxt.getContext());
endNode = s;
} else {
iter = PathEval.eval(graph, s, path, execCxt.getContext());
endNode = o;
}
return evalGroundedOneEnd(binding, iter, endNode, execCxt);
}
代码示例来源:origin: apache/jena
/** 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) ;
// Solve without going through this executor again.
// There would be issues of nested patterns but this is only a
// (filter (bgp...)) or (filter (quadpattern ...)) or sequences of these.
// so there are no nested patterns to reorder.
return QC.execute(op, input, ec2) ;
}
代码示例来源:origin: apache/jena
public FunctionEnvBase(ExecutionContext execCxt)
{
this(execCxt.getContext(), execCxt.getActiveGraph(), execCxt.getDataset()) ;
execContext = execCxt ;
}
代码示例来源:origin: apache/jena
private QueryIterator specialcase(Node gn, Op subOp, QueryIterator input) {
// This is a placeholder for code to specially handle explicitly named
// default graph and union graph.
if (Quad.isDefaultGraph(gn)) {
ExecutionContext cxt2 = new ExecutionContext(execCxt, execCxt.getDataset().getDefaultGraph()) ;
return execute(subOp, input, cxt2) ;
}
// Bad news -- if ( Lib.equals(gn, Quad.tripleInQuad) ) {}
return null ;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
Node predicate, PropFuncArg argObject, ExecutionContext execCxt) {
Context ctx = execCxt.getContext();
Prologue prologue = (Prologue)ctx.get(PROLOGUE);
SparqlService ss = (SparqlService)ctx.get(SPARQL_SERVICE);
Objects.requireNonNull(ss);
QueryExecutionFactory qef = ss.getQueryExecutionFactory();
if(targetNode.isVariable()) {
targetNode = binding.get((Var)targetNode);
if(targetNode != null && targetNode.isBlank()) {
targetNode = null;
if(kNode != null && kNode.isLiteral()) {
Object o = kNode.getLiteralValue();
if(o instanceof Number) {
代码示例来源:origin: apache/jena
DatasetGraph ds = cxt.getDataset() ;
BasicPattern pattern = opQuad.getBasicPattern() ;
if ( ! opQuad.getGraphNode().isVariable() )
if ( ! opQuad.getGraphNode().isURI() )
{ throw new ARQInternalErrorException("Not a URI or variable: "+opQuad.getGraphNode()) ;}
Graph g = null ;
g = ds.getDefaultGraph() ;
else
g = ds.getGraph(opQuad.getGraphNode()) ;
if ( g == null )
return new TableEmpty() ;
ExecutionContext cxt2 = new ExecutionContext(cxt, g) ;
QueryIterator qIter = executeBGP(pattern, QueryIterRoot.create(cxt2), cxt2) ;
return TableFactory.create(qIter) ;
Var gVar = Var.alloc(opQuad.getGraphNode()) ;
for ( Iterator<Node> graphNodes = cxt.getDataset().listGraphNodes() ; graphNodes.hasNext(); )
Graph g = cxt.getDataset().getGraph(gn) ;
Binding b = BindingFactory.binding(BindingRoot.create(), gVar, gn) ;
ExecutionContext cxt2 = new ExecutionContext(cxt, g) ;
代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl
@Override
public QueryIterator exec(Binding binding, PropFuncArg argSubject,
Node predicate, PropFuncArg argObject, ExecutionContext execCxt) {
argSubject = Substitute.substitute(argSubject, binding);
argObject = Substitute.substitute(argObject, binding);
if(!argObject.getArg().isVariable()) {
throw new ExprEvalException("Right hand side of tosh:targetContains must be a variable");
}
Node targetNode = argSubject.getArgList().get(0);
Node shapesGraphNode = argSubject.getArgList().get(1);
Model currentModel = ModelFactory.createModelForGraph(execCxt.getActiveGraph());
Dataset dataset = new DatasetWithDifferentDefaultModel(currentModel, DatasetImpl.wrap(execCxt.getDataset()));
Model model = dataset.getNamedModel(shapesGraphNode.getURI());
Resource target = (Resource) model.asRDFNode(targetNode);
Set<Node> focusNodes = new HashSet<Node>();
SHACLUtil.addNodesInTarget(target, dataset, focusNodes);
return new QueryIterExtendByVar(binding, (Var) argObject.getArg(), focusNodes.iterator(), execCxt);
}
}
代码示例来源:origin: apache/jena
private QueryIterator execEvaluatedCalc(Binding binding, Node containerNode, Node predicate, Node member, ExecutionContext execCxt)
Graph graph = execCxt.getActiveGraph() ;
if ( ! containerNode.isVariable() )
if ( ! GraphContainerUtils.isContainer(execCxt.getActiveGraph(), containerNode, typeNode) )
return IterLib.noResults(execCxt) ;
return oneContainer(binding, containerNode, member, execCxt) ;
if ( member.isVariable() )
c = findContainers(graph, typeNode) ;
else
Var cVar = Var.alloc(containerNode) ;
for ( Node cn : c )
Node m = member;
if ( Var.isVar( member ) && member.equals( cVar ) )
代码示例来源:origin: TopQuadrant/shacl
Node predicateNode = argSubject.getArgList().get(1);
if(predicateNode.isVariable()) {
return IterLib.noResults(execCxt);
Model model = ModelFactory.createModelForGraph(execCxt.getActiveGraph());
Dataset dataset = ARQFactory.get().getDataset(model);
URI shapesGraphURI = URI.create("urn:x-topbraid:dummyShapesGraph");
ShapesGraph shapesGraph = new ShapesGraph(model);
PathEvaluator eval = new PathEvaluator(model.getProperty(predicateNode.getURI()));
if(argObject.getArg().isVariable()) {
if(focusNode.isVariable()) {
代码示例来源:origin: apache/jena
static Table evalDS(OpDatasetNames opDSN, Evaluator evaluator)
{
Node graphNode = opDSN.getGraphNode() ;
if ( graphNode.isURI() )
{
if ( evaluator.getExecContext().getDataset().containsGraph(graphNode) )
{ return new TableUnit() ; }
else
// WRONG
{ return new TableEmpty() ; }
}
if ( ! Var.isVar(graphNode) )
throw new ARQInternalErrorException("OpDatasetNames: Not a URI or variable: "+graphNode) ;
DatasetGraph dsg = evaluator.getExecContext().getDataset() ;
Iterator<Node> iter = dsg.listGraphNodes() ;
List<Binding> list = new ArrayList<>((int)dsg.size()) ;
for ( ; iter.hasNext(); )
{
Node gn = iter.next();
Binding b = BindingFactory.binding(Var.alloc(graphNode), gn) ;
list.add(b) ;
}
QueryIterator qIter = new QueryIterPlainWrapper(list.iterator(), evaluator.getExecContext()) ;
return TableFactory.create(qIter) ;
}
代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl
List<RDFNode> results = new LinkedList<>();
Context cxt = ARQ.getContext().copy();
cxt.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime());
if(!a.isEmpty()) {
int m = y % a.size();
binding.add(Var.alloc("a" + i), a.get(m).asNode());
y /= a.size();
FunctionEnv env = new ExecutionContext(cxt, dsg.getDefaultGraph(), dsg, null);
try {
NodeValue r = expr.eval(binding, env);
代码示例来源:origin: apache/jena
if ( ! Var.isVar(opGraph.getNode()) )
DatasetGraph dsg = execCxt.getDataset() ;
Node graphNode = opGraph.getNode() ;
if ( ! dsg.containsGraph(graphNode) )
return new TableEmpty() ;
Graph graph = execCxt.getDataset().getGraph(opGraph.getNode()) ;
if ( graph == null ) // But contains was true?!!
throw new InternalErrorException("Graph was present, now it's not") ;
ExecutionContext execCxt2 = new ExecutionContext(execCxt, graph) ;
Evaluator e2 = EvaluatorFactory.create(execCxt2) ;
return eval(e2, opGraph.getSubOp()) ;
Var gVar = Var.alloc(opGraph.getNode()) ;
Table current = null ;
for ( Iterator<Node> iter = execCxt.getDataset().listGraphNodes() ; iter.hasNext() ; )
Graph graph = execCxt.getDataset().getGraph(gn) ;
ExecutionContext execCxt2 = new ExecutionContext(execCxt, graph) ;
Evaluator e2 = EvaluatorFactory.create(execCxt2) ;
代码示例来源:origin: apache/jena
private String chooseGraphURI(ExecutionContext execCxt) {
// use the graph information in the text index if possible
String graphURI = null;
Graph activeGraph = execCxt.getActiveGraph();
if (textIndex.getDocDef().getGraphField() != null && activeGraph instanceof NamedGraph) {
NamedGraph namedGraph = (NamedGraph)activeGraph ;
if (!Quad.isUnionGraph(namedGraph.getGraphName())) {
graphURI = namedGraph.getGraphName() != null
? TextQueryFuncs.graphNodeToString(namedGraph.getGraphName())
: Quad.defaultGraphNodeGenerated.getURI() ;
}
}
return graphURI;
}
代码示例来源:origin: apache/jena
public static Procedure build(Node procId, ExprList args, ExecutionContext execCxt)
{
Context context = execCxt.getContext() ;
ProcedureRegistry reg = chooseProcedureRegistry(context) ;
ProcedureFactory f = reg.get(procId.getURI()) ;
Procedure proc = f.create(procId.getURI()) ;
args.prepareExprs(context) ; // Allow args to build as well.
proc.build(procId, args, execCxt) ;
return proc ;
}
代码示例来源:origin: apache/jena
@Override
public QueryIterator execOneList(Binding binding, Node listNode, Node predicate, Node length, ExecutionContext execCxt)
{
Graph graph = execCxt.getActiveGraph() ;
if ( Var.isVar(listNode) )
throw new ARQInternalErrorException("listLength: Subject is a variable") ;
// Case : arg 1 (the list) is bound and arg 2 not bound => generate possibilities
// Case : arg 1 is bound and arg 2 is bound => test for membership.
if ( Var.isVar(length) )
return length(binding, graph, listNode, Var.alloc(length) , execCxt) ;
else
return verify(binding, graph, listNode, length, execCxt) ;
}
代码示例来源:origin: apache/jena
private Iterator<Triple> graphFindWorker(Graph graph, Node s, PropertyFunctionFactory f, Node p, Node o, Context context) {
// Expensive?
PropertyFunction pf = f.create(p.getURI()) ;
PropFuncArg sv = arg(s, "S") ;
PropFuncArg ov = arg(o, "O") ;
QueryIterator r = QueryIterRoot.create(new ExecutionContext(context, graph, null, null)) ;
QueryIterator qIter = pf.exec(r, sv, p, ov, new ExecutionContext(ARQ.getContext(), graph, null, null)) ;
if ( ! qIter.hasNext() )
return Iter.nullIterator() ;
List<Triple> array = new ArrayList<>() ;
for ( ; qIter.hasNext() ; ) {
Binding b = qIter.next() ;
Node st = value(sv, b) ;
Node ot = value(ov, b) ;
array.add(Triple.create(st, p, ot)) ;
}
// Materialise so the inner QueryIterators are used up.
return array.iterator() ;
}
代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl
argObject = Substitute.substitute(argObject, binding);
if(!argObject.getArg().isVariable()) {
throw new ExprEvalException("Right hand side of tosh:exprEval must be a variable");
Node focusNode = argSubject.getArgList().get(1);
Model model = ModelFactory.createModelForGraph(execCxt.getActiveGraph());
Dataset dataset = ARQFactory.get().getDataset(model);
URI shapesGraphURI = URI.create("urn:x-topbraid:dummyShapesGraph");
代码示例来源:origin: apache/jena
@Override
protected QueryIterator execObjectBound(Binding binding, Var listVar, Node predicate, Node length,
ExecutionContext execCxt)
{
Graph graph = execCxt.getActiveGraph() ;
return length(binding, graph, listVar, Var.alloc(length) , execCxt) ;
}
}
代码示例来源:origin: apache/jena
@Override
protected QueryIterator createQueryIter(List<Binding> data) {
QueryIterator qIter = new QueryIterPlainWrapper(data.iterator()) ;
Context cxt = new Context() ;
cxt.set(ARQ.spillToDiskThreshold, 2L);
return new QueryIterDistinct(qIter, new ExecutionContext(cxt, null, null, null)) ;
}
内容来源于网络,如有侵权,请联系作者删除!