Java Code Examples for org.apache.jena.sparql.engine.ExecutionContext#getActiveGraph()
The following examples show how to use
org.apache.jena.sparql.engine.ExecutionContext#getActiveGraph() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryIterTripleStarPattern.java From RDFstarTools with Apache License 2.0 | 6 votes |
public TripleMapper( Binding binding, Triple tp, ExecutionContext cxt ) { super(cxt) ; this.s = ExtendedSubstitute.substitute( tp.getSubject(), binding ); this.p = ExtendedSubstitute.substitute( tp.getPredicate(), binding ); this.o = ExtendedSubstitute.substitute( tp.getObject(), binding ); this.sIsTripleWithVars = isTripleWithVars(s); this.oIsTripleWithVars = isTripleWithVars(o); this.binding = binding; final Node s2 = sIsTripleWithVars ? Node.ANY : convertToBeUsedForFind(s); final Node p2 = convertToBeUsedForFind(p); final Node o2 = oIsTripleWithVars ? Node.ANY : convertToBeUsedForFind(o); final Graph graph = cxt.getActiveGraph(); this.graphIter = graph.find(s2, p2, o2); }
Example 2
Source File: localname.java From xcurator with Apache License 2.0 | 6 votes |
private QueryIterator execAllNodes(Var subjVar, Node nodeLocalname, Binding input, ExecutionContext execCxt) { if ( ! nodeLocalname.isVariable() ) { if ( ! nodeLocalname.isLiteral() ) // Not a variable, not a literal=> can't match return QueryIterNullIterator.create(execCxt) ; if( ! NodeUtils.isSimpleString(nodeLocalname) ) return QueryIterNullIterator.create(execCxt) ; } //Set bindings = new HashSet() ; // Use a Set if you want unique results. List<Binding> bindings = new ArrayList<Binding>() ; // Use a list if you want counting results. Graph graph = execCxt.getActiveGraph() ; ExtendedIterator<Triple>iter = graph.find(Node.ANY, Node.ANY, Node.ANY) ; for ( ; iter.hasNext() ; ) { Triple t = iter.next() ; slot(bindings, input, t.getSubject(), subjVar, nodeLocalname) ; slot(bindings, input, t.getPredicate(), subjVar, nodeLocalname) ; slot(bindings, input, t.getObject(), subjVar, nodeLocalname) ; } return new QueryIterPlainWrapper(bindings.iterator(), execCxt) ; }
Example 3
Source File: StageGeneratorAlt.java From xcurator with Apache License 2.0 | 6 votes |
@Override public QueryIterator execute(BasicPattern pattern, QueryIterator input, ExecutionContext execCxt) { // Just want to pick out some BGPs (e.g. on a particualr graph) // Test :: execCxt.getActiveGraph() if ( ! ( execCxt.getActiveGraph() instanceof GraphBase ) ) // Example: pass on up to the original StageGenerator if // not based on GraphBase (which most Graph implementations are). return other.execute(pattern, input, execCxt) ; System.err.println("MyStageGenerator.compile:: triple patterns = "+pattern.size()) ; // Stream the triple matches together, one triple matcher at a time. QueryIterator qIter = input ; for (Triple triple : pattern.getList()) qIter = new QueryIterTriplePattern(qIter, triple, execCxt) ; return qIter ; }