@Override public Iterator<Triple> find(Node s, Node p, Node o) { if ( s == null ) s = Node.ANY ; if ( p == null ) p = Node.ANY ; if ( o == null ) o = Node.ANY ; return graph.find(s, p ,o) ; }
@Override public ExtendedIterator<Triple> find(Triple triple) { return graph.find(triple) ; }
@Override public ExtendedIterator<Triple> find(Node s, Node p, Node o) { return graph.find(s, p, o) ; }
/** Answer the result of <code>find( t )</code> on the single graph in this union. */ private ExtendedIterator<Triple> singleGraphFind( final Triple t ) { return (m_subGraphs.get( 0 )).find( t ); }
/** * Helper - returns the (singleton) value for the given property on the given * root node in the data graph. */ public static Node getPropValue(Node root, Node prop, Graph context) { return doGetPropValue(context.find(root, prop, null)); }
/** Calculate graph.find(?, rdfs:member, ?) */ public static Iterator<Triple> rdfsMember(Graph graph, Node s, Node o) { ExtendedIterator<Triple> iter = graph.find(s, Node.ANY, o) ; return iter.filterKeep(filterRDFSmember) ; }
/** Answer an iterator over all the reification triples that this Reifier exposes (ie all if Standard, none otherwise) that match m. */ public static ExtendedIterator<Triple> findExposed(Graph graph, Triple match) { ExtendedIterator<Triple> it = graph.find(match) ; it = it.filterKeep(filterReif) ; return WrappedIterator.create(it) ; }
/** * Find all the base triples matching tm, exclude the ones that are deleted, * add the ones that have been added. */ @Override protected ExtendedIterator<Triple> graphBaseFind(Triple t) { ExtendedIterator<Triple> iterator = base.find(t).filterDrop(ifIn(GraphUtil.findAll(deletions))).andThen(additions.find(t)) ; return SimpleEventManager.notifyingRemove( this, iterator ) ; }
/** List the subjects in a graph (no duplicates) */ public static Iterator<Node> listSubjects(Graph graph) { ExtendedIterator<Triple> iter = graph.find(Node.ANY, Node.ANY, Node.ANY) ; return Iter.iter(iter).map(Triple::getSubject).distinct() ; }
/** List the objects in a graph (no duplicates) */ public static Iterator<Node> listObjects(Graph graph) { ExtendedIterator<Triple> iter = graph.find(Node.ANY, Node.ANY, Node.ANY) ; return Iter.iter(iter).map(Triple::getObject).distinct() ; }
/** returns 0,1,2 (where 2 really means "more than 1") */ private int occursAsSubject(Node subj) { if ( dsg != null ) { Iterator<Quad> iter = dsg.find(Node.ANY, subj, Node.ANY, Node.ANY) ; return count012(iter) ; } else { ExtendedIterator<Triple> iter = graph.find(subj, Node.ANY, Node.ANY) ; try { return count012(iter) ; } finally { iter.close() ; } } }
/** returns 0,1,2 (where 2 really means "more than 1") */ private int inLinks(Node obj) { if ( dsg != null ) { Iterator<Quad> iter = dsg.find(Node.ANY, Node.ANY, Node.ANY, obj) ; return count012(iter) ; } else { ExtendedIterator<Triple> iter = graph.find(Node.ANY, Node.ANY, obj) ; try { return count012(iter) ; } finally { iter.close() ; } } }
@Override public void setDefaultGraph(final Graph g) { mutate(graph -> { defaultGraph().clear(); graph.find().forEachRemaining(defaultGraph()::add); }, g); }
private Triple aTriple() { ClosableIterator<Triple> it = null; try { it = graph.find( null, null, null ); return it.hasNext() ? it.next() : null; } finally { if (it != null) it.close(); } }
@Test public void find_union_02() { DatasetGraphBaseFind dsgx = (DatasetGraphBaseFind)dsg ; assertNotNull(dsgx.getUnionGraph()); List<Triple> x = toList(dsgx.getUnionGraph().find(null, null, null)) ; assertEquals(3, x.size()) ; assertTrue(x.contains(q4.asTriple())) ; assertTrue(x.contains(q5.asTriple())) ; assertTrue(x.contains(q10.asTriple())) ; }
@Test public void graphDSG_view_1() { Triple t = makeDefaultGraph(baseDSG).find(null, null, null).next() ; assertEquals(SSE.parseTriple("(<s> <p> 0)"), t) ; // Check exact iterator. }
@ContractTest public void testFind_Triple_ByFluidTriple() { Graph g = graphWith(producer.newInstance(), "x y z "); Set<Triple> expect = tripleSet("x y z"); txnBegin(g); assertEquals(expect, g.find(triple("?? y z")).toSet()); assertEquals(expect, g.find(triple("x ?? z")).toSet()); assertEquals(expect, g.find(triple("x y ??")).toSet()); txnRollback(g); }
@Test public void find3() { Graph plain = GraphPlain.plain(graph); Node s = node("s"); Node p = node("p"); Node x = node("??"); List<Triple> list = plain.find(s,p,x).toList(); assertEquals(3, list.size()); }
@Test public void trig_10() //{ parse("{ <x> <p> <q> }") ; } { DatasetGraph dsg = parse("{ <x> <p> <q> }") ; assertEquals(1, dsg.getDefaultGraph().size()) ; Triple t = dsg.getDefaultGraph().find(null,null,null).next(); Triple t2 = SSE.parseTriple("(<http://base/x> <http://base/p> <http://base/q>)") ; assertEquals(t2, t) ; }