/** * Extended find interface used in situations where the implementator may or may not be able to * answer the complete query. It will attempt to answer the pattern but if its answers are not * known to be complete then it will also pass the request on to the nested Finder to append more * results. * * @param pattern a TriplePattern to be matched against the data * @param continuation either a Finder or a normal Graph which will be asked for additional match * results if the implementor may not have completely satisfied the query. */ @Override public ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation) { if (graph == null) return new NullIterator<Triple>(); if (continuation == null) { return graph.find(pattern.asTripleMatch()); } else { return graph.find(pattern.asTripleMatch()).andThen(continuation.find(pattern)); } }
public static ExtendedIterator predicatesFor(Graph g, Node s, Node o) { Set predicates = CollectionFactory.createHashedSet(); ClosableIterator it = g.find(s, Node.ANY, o); while (it.hasNext()) predicates.add(((Triple) it.next()).getPredicate()); return WrappedIterator.createNoRemove(predicates.iterator()); }
/** * Basic pattern lookup interface. * * @param pattern a TriplePattern to be matched against the data * @return a ClosableIterator over all Triples in the data set that match the pattern */ @Override public ExtendedIterator<Triple> find(TriplePattern pattern) { if (graph == null) return new NullIterator<Triple>(); return graph.find(pattern.asTripleMatch()); }
public static ExtendedIterator subjectsFor(Graph g, Node p, Node o) { Set objects = CollectionFactory.createHashedSet(); ClosableIterator it = g.find(Node.ANY, p, o); while (it.hasNext()) objects.add(((Triple) it.next()).getSubject()); return WrappedIterator.createNoRemove(objects.iterator()); }