org.apache.jena.graph.Graph.find()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(200)

本文整理了Java中org.apache.jena.graph.Graph.find()方法的一些代码示例,展示了Graph.find()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.find()方法的具体详情如下:
包路径:org.apache.jena.graph.Graph
类名称:Graph
方法名:find

Graph.find介绍

[英]Returns an iterator over all Triples in the graph. Equivalent to find(Node.ANY, Node.ANY, Node.ANY)
[中]返回图中所有三元组的迭代器。等同于查找(Node.ANY、Node.ANY、Node.ANY)

代码示例

代码示例来源:origin: apache/jena

@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) ;
}

代码示例来源:origin: apache/jena

@Override
public ExtendedIterator<Triple> find(Triple triple)
{
  return graph.find(triple) ;
}

代码示例来源:origin: apache/jena

@Override
public ExtendedIterator<Triple> find(Node s, Node p, Node o)
{
  return graph.find(s, p, o) ;
}

代码示例来源:origin: apache/jena

/**
   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  ); }

代码示例来源:origin: apache/jena

/**
 * 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));
}

代码示例来源:origin: apache/jena

/** 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)  ;
}

代码示例来源:origin: apache/jena

/**
  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) ;
}

代码示例来源:origin: apache/jena

/**
 * 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 ) ;
}

代码示例来源:origin: apache/jena

/** 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() ;
}

代码示例来源:origin: apache/jena

/** 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() ;
}

代码示例来源:origin: apache/jena

/** 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() ; }
  }
}

代码示例来源:origin: apache/jena

/** 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() ; }
  }
}

代码示例来源:origin: apache/jena

@Override
public void setDefaultGraph(final Graph g) {
  mutate(graph -> {
    defaultGraph().clear();
    graph.find().forEachRemaining(defaultGraph()::add);
  }, g);
}

代码示例来源:origin: apache/jena

public void testFind()
{
  Graph g = getGraph();
  graphAdd( g, "S P O" );
  assertDiffer( new HashSet<Triple>(), g.find( Node.ANY, Node.ANY, Node.ANY ).toSet() );
  assertDiffer( new HashSet<Triple>(), g.find( Triple.ANY ).toSet() );
}

代码示例来源:origin: apache/jena

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(); }
  }

代码示例来源:origin: apache/jena

@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())) ;
}

代码示例来源:origin: apache/jena

@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.
}

代码示例来源:origin: apache/jena

@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);
}

代码示例来源:origin: apache/jena

@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());
}

代码示例来源:origin: apache/jena

@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) ;
}

相关文章