jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [5/9] jena git commit: JENA-1074: Add DatasetGraph.getUnionGraph
Date Thu, 08 Jun 2017 14:38:23 GMT
JENA-1074: Add DatasetGraph.getUnionGraph

A graph which is the triples fromall named graph in the dataset.
This does not include the default graph.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/0a872489
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/0a872489
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/0a872489

Branch: refs/heads/master
Commit: 0a872489d859a78cf0e9e13b2a8ce532a5751d5d
Parents: 462fe53
Author: Andy Seaborne <andy@apache.org>
Authored: Sun Jun 4 09:44:34 2017 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Sun Jun 4 09:44:34 2017 +0100

----------------------------------------------------------------------
 .../java/org/apache/jena/sparql/core/DatasetGraph.java    |  7 +++++++
 .../org/apache/jena/sparql/core/DatasetGraphBase.java     | 10 ++++++++++
 .../org/apache/jena/sparql/core/DatasetGraphWrapper.java  |  4 ++++
 3 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/0a872489/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraph.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraph.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraph.java
index d772624..313af4d 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraph.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraph.java
@@ -49,6 +49,13 @@ public interface DatasetGraph extends Transactional, Closeable
     public Graph getGraph(Node graphNode) ;
     
     /**
+     * Return a {@link Graph} that is the union of all named graphs in this dataset. This
+     * union graph is read-only (its prefix mapping in the current JVM may be changed but
+     * that may not persist).
+     */
+    public Graph getUnionGraph();
+    
+    /**
      * Does the DatasetGraph contain a specific named graph? 
      * Whether a dataset contains a graph if there are no triples is
      * not defined - see the specifc implementation. Some datasets are "open" -

http://git-wip-us.apache.org/repos/asf/jena/blob/0a872489/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphBase.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphBase.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphBase.java
index e5214eb..73847fe 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphBase.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphBase.java
@@ -26,6 +26,7 @@ import org.apache.jena.graph.Node ;
 import org.apache.jena.shared.Lock ;
 import org.apache.jena.shared.LockMRSW ;
 import org.apache.jena.sparql.core.mem.DatasetGraphInMemory ;
+import org.apache.jena.sparql.graph.GraphOps;
 import org.apache.jena.sparql.sse.writers.WriterGraph ;
 import org.apache.jena.sparql.util.Context ;
 
@@ -58,6 +59,15 @@ abstract public class DatasetGraphBase implements DatasetGraph
     
     @Override
     public abstract Graph getDefaultGraph() ;
+    
+    @Override
+    public Graph getUnionGraph() {
+        // Implementations are encouraged to implement an efficent
+        // {@code DatasetGraphBase.findQuadsInUnionGraph} or
+        // {@code findNG(Quad.unionGraph, Node.ANY, Node.ANY, Node.ANY)}
+        // for a distinct iterator (e.g. avoid calling "distinct()" by not creating duplicates).
+        return GraphOps.unionGraph(this);
+    }
 
     @Override
     public abstract Graph getGraph(Node graphNode) ;

http://git-wip-us.apache.org/repos/asf/jena/blob/0a872489/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWrapper.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWrapper.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWrapper.java
index 3480fd4..421fdc0 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWrapper.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWrapper.java
@@ -82,6 +82,10 @@ public class DatasetGraphWrapper implements DatasetGraph, Sync
     { return getG().getDefaultGraph(); }
 
     @Override
+    public Graph getUnionGraph()
+    { return getG().getUnionGraph(); }
+
+    @Override
     public Graph getGraph(Node graphNode)
     { return getG().getGraph(graphNode) ; }
 


Mime
View raw message