/* Count the triples for the graph.find */ public static long countTriples(Graph graph, Node s, Node p, Node o) { ExtendedIterator<Triple> iter = graph.find(s, p, o); try { return Iter.count(iter); } finally { iter.close(); } }
public static Map<Node, Graph> indexBySubject(Graph graph) { ExtendedIterator<Triple> it = graph.find(Node.ANY, Node.ANY, Node.ANY); Map<Node, Graph> result; try { result = indexBySubject(it); } finally { it.close(); } return result; }
/** Get exactly one triple or null for none or more than one. */ public static Triple triple1(Graph graph, Node s, Node p, Node o) { ExtendedIterator<Triple> iter = graph.find(s, p, o); try { if (!iter.hasNext()) return null; Triple t = iter.next(); if (iter.hasNext()) return null; return t; } finally { iter.close(); } }
@Override public ExtendedIterator<Triple> find(Node s, Node p, Node o) { return SimpleEventManager.notifyingRemove(this, base.find(s, p, o)); }
@Override public ExtendedIterator<Triple> find(Triple m) { return SimpleEventManager.notifyingRemove(this, base.find(m)); }
private static void addAll(Graph srcGraph, Graph dstGraph) { Iterator<Triple> triples = srcGraph.find(Node.ANY, Node.ANY, Node.ANY); triples.forEachRemaining(dstGraph::add); }
/** Collect all the matching triples */ public static void accTriples(Collection<Triple> acc, Graph graph, Node s, Node p, Node o) { ExtendedIterator<Triple> iter = graph.find(s, p, o); for (; iter.hasNext(); ) acc.add(iter.next()); iter.close(); }