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<Triple>() ;
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.