You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2014/12/23 12:09:05 UTC

[2/3] jena git commit: JENA-834 : Code to make TDB work for both RDF 1.0 and RDF 1.1.

JENA-834 : Code to make TDB work for both RDF 1.0 and RDF 1.1.

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

Branch: refs/heads/master
Commit: e801bd1bb9f7305b6c87aa1e872e79a59a39cce0
Parents: 45fbca7
Author: Andy Seaborne <an...@apache.org>
Authored: Tue Dec 23 11:08:23 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Tue Dec 23 11:08:23 2014 +0000

----------------------------------------------------------------------
 .../main/java/com/hp/hpl/jena/tdb/lib/NodeLib.java | 13 +++++++++----
 .../main/java/com/hp/hpl/jena/tdb/store/Hash.java  |  2 +-
 .../java/com/hp/hpl/jena/tdb/store/NodeId.java     | 11 ++++++++---
 .../java/com/hp/hpl/jena/tdb/store/NodeType.java   |  1 +
 .../hp/hpl/jena/tdb/store/nodetable/NodecSSE.java  | 17 +++++++++--------
 5 files changed, 28 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/e801bd1b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/lib/NodeLib.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/lib/NodeLib.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/lib/NodeLib.java
index 291d10c..d63396e 100644
--- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/lib/NodeLib.java
+++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/lib/NodeLib.java
@@ -36,6 +36,7 @@ import org.apache.jena.atlas.logging.Log ;
 import org.apache.jena.riot.out.NodeFmtLib ;
 
 import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.sparql.util.NodeUtils ;
 import com.hp.hpl.jena.tdb.TDBException ;
 import com.hp.hpl.jena.tdb.base.block.Block ;
 import com.hp.hpl.jena.tdb.base.objectfile.ObjectFile ;
@@ -126,10 +127,14 @@ public class NodeLib
                 hash(h, n.getBlankNodeLabel(), null, null, nt) ;
                 return ;
             case LITERAL:
-                hash(h,
-                     n.getLiteralLexicalForm(),
-                     n.getLiteralLanguage(),
-                     n.getLiteralDatatypeURI(), nt) ;
+                String dt = n.getLiteralDatatypeURI() ;
+                if ( NodeUtils.isSimpleString(n) || NodeUtils.isLangString(n) ) {
+                    // RDF 1.1 : No datatype for:
+                    //   xsd:String as simple literals
+                    //   rdf:langString and @ 
+                    dt = null ;
+                }
+                hash(h, n.getLiteralLexicalForm(), n.getLiteralLanguage(), dt, nt) ;
                 return  ;
             case OTHER:
                 throw new TDBException("Attempt to hash something strange: "+n) ; 

http://git-wip-us.apache.org/repos/asf/jena/blob/e801bd1b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/Hash.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/Hash.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/Hash.java
index 8696694..0ddbc93 100644
--- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/Hash.java
+++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/Hash.java
@@ -26,7 +26,7 @@ import org.apache.jena.atlas.lib.Bytes ;
 /** Hash values. */ 
 public class Hash
 {
-    byte [] bytes ;
+    private byte [] bytes ;
     public Hash(int len) { bytes = new byte[len] ; }
     public int getLen() { return bytes.length ; }
     public byte [] getBytes() { return bytes ; }

http://git-wip-us.apache.org/repos/asf/jena/blob/e801bd1b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java
index cc82642..0cc9cf3 100644
--- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java
+++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java
@@ -31,6 +31,7 @@ import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.graph.NodeFactory ;
 import com.hp.hpl.jena.graph.impl.LiteralLabel ;
 import com.hp.hpl.jena.sparql.graph.NodeConst ;
+import com.hp.hpl.jena.sparql.util.NodeUtils ;
 import com.hp.hpl.jena.tdb.TDBException ;
 import com.hp.hpl.jena.tdb.sys.SystemTDB ;
 
@@ -162,10 +163,14 @@ public class NodeId
             return null ;
         }
         
-        if ( ! node.isLiteral() ) return null ;
-        if ( node.getLiteralDatatype() == null ) return null ;
+        if ( ! enableInlineLiterals )
+            return null ;
+
+        if ( ! node.isLiteral() )  
+            return null ;
         
-        if ( ! enableInlineLiterals ) return null ;
+        if ( NodeUtils.isSimpleString(node) || NodeUtils.isLangString(node) )
+            return null ;
         
         try { return inline$(node) ; }
         catch (Throwable th) {

http://git-wip-us.apache.org/repos/asf/jena/blob/e801bd1b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeType.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeType.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeType.java
index 4720bcf..c34bc4b 100644
--- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeType.java
+++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeType.java
@@ -24,6 +24,7 @@ import com.hp.hpl.jena.sparql.util.Named;
 
 import com.hp.hpl.jena.tdb.TDBException;
 
+// Currently unused.
 public enum NodeType implements Named
 {
     // Do not allocate id 0

http://git-wip-us.apache.org/repos/asf/jena/blob/e801bd1b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/nodetable/NodecSSE.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/nodetable/NodecSSE.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/nodetable/NodecSSE.java
index 4d9c1f7..6390eff 100644
--- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/nodetable/NodecSSE.java
+++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/nodetable/NodecSSE.java
@@ -35,6 +35,7 @@ import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.graph.NodeFactory ;
 import com.hp.hpl.jena.rdf.model.AnonId ;
 import com.hp.hpl.jena.shared.PrefixMapping ;
+import com.hp.hpl.jena.sparql.util.NodeUtils ;
 import com.hp.hpl.jena.tdb.TDBException ;
 import com.hp.hpl.jena.tdb.lib.StringAbbrev ;
 
@@ -70,7 +71,7 @@ public class NodecSSE implements Nodec
                 node = NodeFactory.createURI(x) ; 
         }
         
-        if ( node.isLiteral() && node.getLiteralLanguage() != null )
+        if ( node.isLiteral() && NodeUtils.isLangString(node) )
         {
             // Check syntactically valid.
             String lang = node.getLiteralLanguage() ;
@@ -150,14 +151,14 @@ public class NodecSSE implements Nodec
             return 2+maxLength(node.getURI()) ;
         if ( node.isLiteral() )
         {
-            if ( node.getLiteralDatatypeURI() != null )
+            int len = 2+maxLength(node.getLiteralLexicalForm()) ;
+            if ( NodeUtils.isLangString(node) )
+                // Space for @ (language tag is ASCII)
+                len = len + 3 + node.getLiteralLanguage().length() ;
+            else if ( ! NodeUtils.isSimpleString(node) )
                 // The quotes and also space for ^^<>
-                return 6+maxLength(node.getLiteralLexicalForm())+maxLength(node.getLiteralDatatypeURI()) ;
-            else if ( node.getLiteralLanguage() != null )
-                // The quotes and also space for @ (language tag is ASCII)
-                return 3+maxLength(node.getLiteralLexicalForm())+node.getLiteralLanguage().length() ;
-            else
-                return 2+maxLength(node.getLiteralLexicalForm()) ;
+                len = len + 4 + maxLength(node.getLiteralDatatypeURI()) ;
+            return len ;
         }
         if ( node.isVariable() )
             // "?"