commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [2/3] incubator-commonsrdf git commit: JenaDatasetImpl correct quad count
Date Fri, 04 Nov 2016 00:50:28 GMT
JenaDatasetImpl correct quad count

.. as previous DatasetGraph.size()  simply returned number of graphs
rather than quads, now we count triples in each named graph and add the
count of triples in the default graph.


Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/a0484867
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/a0484867
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/a0484867

Branch: refs/heads/master
Commit: a04848671707551523208516db145c3c946b6e05
Parents: acc502d
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Fri Nov 4 00:04:34 2016 +0000
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Fri Nov 4 00:44:37 2016 +0000

----------------------------------------------------------------------
 .../org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/a0484867/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
index 2cb0876..f96fc62 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
@@ -23,6 +23,7 @@ import static org.apache.jena.graph.Node.ANY;
 import java.io.StringWriter;
 import java.util.Optional;
 import java.util.UUID;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import org.apache.commons.rdf.api.BlankNodeOrIRI;
@@ -120,7 +121,10 @@ class JenaDatasetImpl implements JenaDataset {
 
     @Override
     public long size() {
-        return graph.size();
+        long quads = Iter.asStream(graph.listGraphNodes())
+                .map(graph::getGraph)
+                .collect(Collectors.summingLong(org.apache.jena.graph.Graph::size));
+        return quads + graph.getDefaultGraph().size();
     }
 
     @Override
@@ -145,8 +149,8 @@ class JenaDatasetImpl implements JenaDataset {
 
     @Override
     public Graph getGraph() {
-        GraphView gv = GraphView.createDefaultGraph(graph);
-        return new JenaGraphImpl(gv, salt);
+        GraphView g = GraphView.createDefaultGraph(graph);
+        return new JenaGraphImpl(g, salt);
     }
 
     @Override


Mime
View raw message