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

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

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

Graph.size介绍

[英]For a concrete graph this returns the number of triples in the graph. For graphs which might infer additional triples it results an estimated lower bound of the number of triples. For example, an inference graph might return the number of triples in the raw data graph.
[中]对于具体的图形,它返回图形中三元组的数量。对于可能推断出额外三元组的图,它得到了三元组数量的估计下限。例如,推理图可能返回原始数据图中的三元组数。

代码示例

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

@Test public void graphDSG_view_union_3()
{
  Graph g = GraphView.createUnionGraph(baseDSG) ;
  assertEquals(2, g.size()) ;
}

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

@Test public void graph_01()
{
  Graph g = emptyGraph() ;
  assertEquals(0, g.size()) ;
  returnGraph(g) ;
}

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

@Test public void count_01()
{
  Graph g = emptyGraph() ;
  assertEquals(0, g.size()) ;
  Triple t1 = triple(s1, p1, o1) ;
  g.add(t1) ;
  assertEquals(1, g.size()) ;
  returnGraph(g) ;
}

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

@Test
public void load_dataset_02() {
  DatasetGraph dsg = fresh() ;
  load(dsg, maker , DIR + "data-1.nq", DIR + "data-2.nt") ;
  Txn.executeRead(dsg, ()->{
    assertEquals(1, dsg.getGraph(g).size()) ;
    assertEquals(2, dsg.getDefaultGraph().size());
  });
}

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

@Test
public void load_graph_1() {
  DatasetGraph dsg = fresh() ;
  load(dsg, gn, maker, DIR + "data-2.nt") ;
  Txn.executeRead(dsg, ()->{
    assertEquals(0, dsg.getDefaultGraph().size());
    assertEquals(2, dsg.getGraph(gn).size());
  });
}

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

@Test
public void load_graph_01() {
  DatasetGraphTDB dsg = fresh() ;
  TDBLoader.load(dsg, DIR + "data-2.nt", false) ;
  assertEquals(1, dsg.getDefaultGraph().size()) ;
}

代码示例来源:origin: org.apache.jena/jena-tdb

@Test
public void load_graph_01() {
  DatasetGraphTDB dsg = fresh() ;
  TDBLoader.load(dsg, DIR + "data-2.nt", false) ;
  assertEquals(1, dsg.getDefaultGraph().size()) ;
}

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

@Test public void labels_01() {
  Graph graph = GraphFactory.createGraphMem();
  //LabelToNode.createUseLabelEncoded() ;
  
  builder()
    .labelToNode(LabelToNode.createUseLabelAsGiven())
    .parse(graph);
  assertEquals(1, graph.size());
  StringWriter sw = new StringWriter();
  RDFDataMgr.write(sw, graph, Lang.NT);
  String s = sw.toString();
  assertTrue(s.contains("_:Bb"));
}

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

@Test
public void dataset_1() {
  // This must parse to <g>
  DatasetGraph dsg = parseToDataset("<x> <p> <s> <g> .");
  assertEquals(1, dsg.size());
  assertEquals(1, dsg.getGraph(NodeFactory.createURI("g")).size());
  assertEquals(0, dsg.getDefaultGraph().size());
}

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

@Test public void graphDSG_view_4()
{
  Graph g = makeNamedGraph(baseDSG, gnNotSuchGraph) ;
  long x = Iter.count(baseDSG.find(gnNotSuchGraph, null, null, null)) ;
  assertEquals(0, x) ;
  assertEquals(0, g.size()) ;
}

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

@Test public void source_shortcut_01() {
  Graph graph = GraphFactory.createGraphMem();
  RDFParser.fromString(testdata).lang(Lang.TTL).parse(graph);
  assertEquals(1, graph.size());
}

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

@Test(expected=RiotNotFoundException.class)
public void source_notfound_2() {
  // Last source wins.
  Graph graph = GraphFactory.createGraphMem();
  RDFParser.create()
    .source(DIR+"data.nosuchfile.ttl")
    .parse(graph);
  assertEquals(3, graph.size());
}

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

@Test
public void load_graph_02() {
  DatasetGraphTDB dsg = fresh() ;
  TDBLoader.load(dsg.getDefaultGraphTDB(), DIR + "data-2.nt", false) ;
  assertEquals(1, dsg.getDefaultGraph().size()) ;
}

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

@Test public void load1() {
  DatasetGraph gs = graphStore() ;
  UpdateRequest req = UpdateFactory.create("LOAD <"+DIR+"/D.nt>") ;
  UpdateAction.execute(req, gs) ;
  assertEquals(1, gs.getDefaultGraph().size()) ;
  assertFalse( gs.listGraphNodes().hasNext()) ;
}

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

@Test
public void source_uri_03() {
  Graph graph = GraphFactory.createGraphMem();
  RDFParser.create().source("file:"+DIR+"data.unknown").lang(Lang.TTL).parse(graph);
  assertEquals(3, graph.size());
}

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

@Test
public void source_uri_05() {
  // Last source wins.
  Graph graph = GraphFactory.createGraphMem();
  RDFParser.create()
    .source("http://example/")
    .source(DIR+"data.ttl")
    .parse(graph);
  assertEquals(3, graph.size());
}

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

@Test
public void source_uri_force_lang() {
  Graph graph = GraphFactory.createGraphMem();
  RDFParser.create().source("file:"+DIR+"data.rdf").forceLang(Lang.TTL).parse(graph);
  assertEquals(3, graph.size());
}

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

@Test public void remove_03()
{
  Graph g = emptyGraph() ;
  Triple t1 = triple(s1, p1, o1) ;
  g.add(t1) ;
  g.remove(s1, any, any) ;
  assertEquals(0, g.size()) ;
  returnGraph(g) ;
}

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

@Test public void source_not_uri_01() {
  Graph graph = GraphFactory.createGraphMem();
  RDFParserBuilder.create().lang(Lang.TTL).fromString(testdata).parse(graph);
  assertEquals(1, graph.size());
}

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

@Test
public void source_string() {
  Graph graph = GraphFactory.createGraphMem();
  RDFParser.create().fromString("<x> <p> <z> .")
    .lang(Lang.NT)
    .parse(graph);
  assertEquals(1, graph.size());
}

相关文章