commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [4/7] incubator-commonsrdf git commit: Dataset pass on its salt to its constituent graphs
Date Fri, 07 Oct 2016 15:00:28 GMT
Dataset pass on its salt to its constituent graphs


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

Branch: refs/heads/rdf4j
Commit: 62fe6b3843012c536ff25664773d542d3a7ac56e
Parents: 88c75a9
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Fri Oct 7 15:57:00 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Fri Oct 7 15:57:00 2016 +0100

----------------------------------------------------------------------
 .../rdf/rdf4j/impl/AbstractRepositoryGraphLike.java      | 11 +++++++----
 .../commons/rdf/rdf4j/impl/InternalRDF4JFactory.java     |  6 +++---
 .../commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java    | 11 +++++++----
 .../commons/rdf/rdf4j/impl/RepositoryGraphImpl.java      |  5 +++--
 4 files changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/62fe6b38/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
index a0c577f..6a1aae6 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
@@ -18,6 +18,7 @@
 package org.apache.commons.rdf.rdf4j.impl;
 
 import java.util.Optional;
+import java.util.UUID;
 
 import org.apache.commons.rdf.api.BlankNodeOrIRI;
 import org.apache.commons.rdf.api.IRI;
@@ -37,17 +38,19 @@ abstract class AbstractRepositoryGraphLike<T extends TripleLike<BlankNodeOrIRI,
 	protected final boolean includeInferred;
 	protected final boolean handleInitAndShutdown;
 	protected final RDF4JTermFactory rdf4jTermFactory;
+	protected final UUID salt;
 
-	AbstractRepositoryGraphLike(Repository repository, boolean handleInitAndShutdown, boolean
includeInferred) {
+	AbstractRepositoryGraphLike(Repository repository, UUID salt, boolean handleInitAndShutdown,
boolean includeInferred) {
 		this.repository = repository;
+		this.salt = salt;
 		this.includeInferred = includeInferred;
 		this.handleInitAndShutdown = handleInitAndShutdown;
 		if (handleInitAndShutdown && !repository.isInitialized()) {
 			repository.initialize();
 		}
-		rdf4jTermFactory = new RDF4JTermFactory(repository.getValueFactory());
-	}
-
+		rdf4jTermFactory = new RDF4JTermFactory(repository.getValueFactory(), salt);
+	}	
+	
 	@Override
 	public void close() throws Exception {
 		if (handleInitAndShutdown) {

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/62fe6b38/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
index 2a5fad5..fa4344f 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
@@ -45,7 +45,7 @@ import org.eclipse.rdf4j.repository.Repository;
  * {@link RDF4JTermFactory} methods like
  * {@link RDF4JTermFactory#createBlankNode()},
  * {@link RDF4JTermFactory#asRDFTerm(org.eclipse.rdf4j.model.Value)} and
- * {@link RDF4JTermFactory#asRDFTermGraph(Repository)}.
+ * {@link RDF4JTermFactory#asRDFTermGraph(Repository, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)}
  * <p>
  * This class exists as a <code>public</code> bridge between the packages
  * {@link org.apache.commons.rdf.rdf4j} and
@@ -139,7 +139,7 @@ public abstract class InternalRDF4JFactory {
 	 */
 	public RDF4JDataset createRepositoryDatasetImpl(Repository repository, boolean handleInitAndShutdown,
 			boolean includeInferred) {
-		return new RepositoryDatasetImpl(repository, handleInitAndShutdown, includeInferred);
+		return new RepositoryDatasetImpl(repository, UUID.randomUUID(), handleInitAndShutdown,
includeInferred);
 	}
 
 	/**
@@ -164,7 +164,7 @@ public abstract class InternalRDF4JFactory {
 	 */
 	public RDF4JGraph createRepositoryGraphImpl(Repository repository, boolean handleInitAndShutdown,
 			boolean includeInferred, Resource... contextMask) {
-		return new RepositoryGraphImpl(repository, handleInitAndShutdown, includeInferred, contextMask);
+		return new RepositoryGraphImpl(repository, UUID.randomUUID(), handleInitAndShutdown, includeInferred,
contextMask);
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/62fe6b38/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
index 2efef42..64f3bbd 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
@@ -19,6 +19,7 @@ package org.apache.commons.rdf.rdf4j.impl;
 
 import java.util.ConcurrentModificationException;
 import java.util.Optional;
+import java.util.UUID;
 import java.util.stream.Stream;
 
 import org.apache.commons.rdf.api.BlankNodeOrIRI;
@@ -40,8 +41,8 @@ import org.eclipse.rdf4j.repository.RepositoryResult;
 
 class RepositoryDatasetImpl extends AbstractRepositoryGraphLike<Quad> implements RDF4JDataset,
Dataset {
 
-	RepositoryDatasetImpl(Repository repository, boolean handleInitAndShutdown, boolean includeInferred)
{
-		super(repository, handleInitAndShutdown, includeInferred);
+	RepositoryDatasetImpl(Repository repository, UUID salt, boolean handleInitAndShutdown, boolean
includeInferred) {
+		super(repository, salt, handleInitAndShutdown, includeInferred);
 	}
 
 	@Override
@@ -197,14 +198,16 @@ class RepositoryDatasetImpl extends AbstractRepositoryGraphLike<Quad>
implements
 	@Override
 	public Graph getGraph() {
 		// default context only
-		return new RepositoryGraphImpl(repository, false, includeInferred, (Resource)null);
+		// NOTE: We carry over the 'salt' as the graph's BlankNode should be equal to our BlankNodes
+		return new RepositoryGraphImpl(repository, salt, false, includeInferred, (Resource)null);
 	}
 
 	@Override
 	public Optional<Graph> getGraph(BlankNodeOrIRI graphName) {
 		// NOTE: May be null to indicate default context
 		Resource context = (Resource) rdf4jTermFactory.asValue(graphName);
-		return Optional.of(new RepositoryGraphImpl(repository, false, includeInferred, context));
+		// NOTE: We carry over the 'salt' as the graph's BlankNode should be equal to our BlankNodes
+		return Optional.of(new RepositoryGraphImpl(repository, salt, false, includeInferred, context));
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/62fe6b38/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
index 52eda30..58eff70 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
@@ -22,6 +22,7 @@ import java.util.ConcurrentModificationException;
 import java.util.HashSet;
 import java.util.Objects;
 import java.util.Set;
+import java.util.UUID;
 import java.util.stream.Stream;
 
 import org.apache.commons.rdf.api.BlankNodeOrIRI;
@@ -45,8 +46,8 @@ class RepositoryGraphImpl extends AbstractRepositoryGraphLike<Triple>
implements
 	
 	private final Resource[] contextMask;
 
-	RepositoryGraphImpl(Repository repository, boolean handleInitAndShutdown, boolean includeInferred,
Resource... contextMask) {
-		super(repository, handleInitAndShutdown, includeInferred);
+	RepositoryGraphImpl(Repository repository, UUID salt, boolean handleInitAndShutdown, boolean
includeInferred, Resource... contextMask) {
+		super(repository, salt, handleInitAndShutdown, includeInferred);
 		this.contextMask = Objects.requireNonNull(contextMask);
 	}
 


Mime
View raw message