clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From enrid...@apache.org
Subject [1/2] git commit: CLEREZZA-865: Changed the method to preserve the mapping of bnodes in virtuoso graphs with the internal representation.
Date Wed, 15 Jan 2014 11:19:22 GMT
Updated Branches:
  refs/heads/master 5a2fdcebf -> 0a3c1ddf7


CLEREZZA-865: Changed the method to preserve the mapping of bnodes in virtuoso graphs with
the internal representation.


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

Branch: refs/heads/master
Commit: b5c55ac9109dc596ff56bc7f64bd1644a8160102
Parents: 5a2fdce
Author: enridaga <enridaga@apache.org>
Authored: Wed Jan 15 10:14:36 2014 +0000
Committer: enridaga <enridaga@apache.org>
Committed: Wed Jan 15 10:14:36 2014 +0000

----------------------------------------------------------------------
 .../rdf/virtuoso/storage/VirtuosoMGraph.java    | 37 ++++++++++++--------
 .../virtuoso/storage/VirtuosoMGraphTest.java    |  1 +
 2 files changed, 23 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/b5c55ac9/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
b/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
index 9b6641f..b0713a2 100644
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
+++ b/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
@@ -70,7 +70,7 @@ public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 	 * Bidirectional map for managing the conversion from virtuoso blank nodes
 	 * (strings) to clerezza blank nodes and vice versa.
 	 */
-	private final BidiMap<String, BNode> bnodesMap;
+//	private final BidiMap<String, BNode> bnodesMap;
 	private int maxVirtBnodeIndex = 0;
 
 	/**
@@ -102,7 +102,7 @@ public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 				provider);
 		this.name = name;
 		this.provider  = provider;
-		this.bnodesMap = new BidiMapImpl<String, BNode>();
+//		this.bnodesMap = new BidiMapImpl<String, BNode>();
 	}
 
 	/**
@@ -556,15 +556,17 @@ public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 	 * @param virtbnode
 	 * @return
 	 */
-	private BNode toBNode(String virtbnode) {
+	private VirtuosoBNode toBNode(String virtbnode) {
 		logger.debug("toBNode(String {})", virtbnode);
-		BNode bnode = bnodesMap.get(virtbnode);
-		if (bnode == null) {
-			bnode = new BNode();
+//		VirtuosoBNode bnode = bnodesMap.get(virtbnode);
+		VirtuosoBNode bnode;
+//		if (bnode == null) {
+			//bnode = new BNode();
+			bnode = new VirtuosoBNode(virtbnode);
 			// skolemize so we get it in future queries
 			//bnodesMap.put(virtbnode.replaceFirst("nodeID://", "_:"), bnode);
-			bnodesMap.put(new StringBuilder().append('<').append(virtbnode).append('>').toString(),
bnode);
-		}
+//			bnodesMap.put(new StringBuilder().append('<').append(virtbnode).append('>').toString(),
bnode);
+//		}
 		// Subject is BNode
 		return bnode;
 	}
@@ -588,14 +590,19 @@ public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 	 */
 	private String toVirtBnode(BNode bnode) {
 		logger.debug("toVirtBnode(BNode {})", bnode);
-		String virtBnode = bnodesMap.getKey(bnode);
-		
-		if (virtBnode == null) {
-			// We create a local bnode mapped to the BNode given
-			virtBnode = nextVirtBnode();
-			bnodesMap.put(virtBnode, bnode);
+//		String virtBnode = bnodesMap.getKey(bnode);
+//		
+//		if (virtBnode == null) {
+//			// We create a local bnode mapped to the BNode given
+//			virtBnode = nextVirtBnode();
+//			bnodesMap.put(virtBnode, bnode);
+//		}
+//		return virtBnode;
+		if(bnode instanceof VirtuosoBNode){
+			return ((VirtuosoBNode) bnode).asSkolemIri();
+		}else{
+			return nextVirtBnode();
 		}
-		return virtBnode;
 	}
 
 	private String getAddSQLStatement(Triple triple) {

http://git-wip-us.apache.org/repos/asf/clerezza/blob/b5c55ac9/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/VirtuosoMGraphTest.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/VirtuosoMGraphTest.java
b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/VirtuosoMGraphTest.java
index a597c78..c4ce126 100644
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/VirtuosoMGraphTest.java
+++ b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/VirtuosoMGraphTest.java
@@ -197,6 +197,7 @@ public class VirtuosoMGraphTest {
 		assertNotNull(t);
 		
 		//NonLiteral s = t.getSubject();
+		log.info("{}",t.getSubject());
 		it = mgraph.filter(t.getSubject(), predicate, t.getObject());
 		found = false;
 		while (it.hasNext()) {


Mime
View raw message