Author: andy
Date: Mon Jun 23 20:10:07 2014
New Revision: 1604921

URL: http://svn.apache.org/r1604921
Log:
JENA-721 : Extenal switch to turn off inline NodeIds.

Modified:
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java
    jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java

Modified: 
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java
URL: 
http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java?rev=1604921&r1=1604920&r2=1604921&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java 
(original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java Mon 
Jun 23 20:10:07 2014
@@ -40,7 +40,7 @@ public class NodeId
     public static final NodeId NodeDoesNotExist = new NodeId(-8) ;
     public static final NodeId NodeIdAny = new NodeId(-9) ;
     
-    private static boolean enableInlineLiterals = true ;
+    private static final boolean enableInlineLiterals = 
SystemTDB.enableInlineLiterals ;
     
     public static final int SIZE = SystemTDB.SizeOfLong ;
     final long value ;

Modified: 
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java
URL: 
http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java?rev=1604921&r1=1604920&r2=1604921&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java 
(original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java 
Mon Jun 23 20:10:07 2014
@@ -23,6 +23,7 @@ import java.io.IOException ;
 import java.nio.ByteOrder ;
 import java.util.Properties ;
 
+import org.apache.jena.atlas.io.IO ;
 import org.apache.jena.atlas.lib.PropertyUtils ;
 import org.apache.jena.atlas.logging.Log ;
 import org.slf4j.Logger ;
@@ -150,10 +151,6 @@ public class SystemTDB
     /** order of an in-memory BTree or B+Tree */
     public static final int OrderMem                = 5 ; // 
intValue("OrderMem", 5) ;
     
-    // -- Settable parameters
-
-    public static Properties global = new Properties() ;
-    
     /** Size, in bytes, of a segment (used for memory mapped files) */
     public static final int SegmentSize             = 8*1024*1024 ; // 
intValue("SegmentSize", 8*1024*1024) ;
     
@@ -191,6 +188,37 @@ public class SystemTDB
     public static ReorderTransformation defaultOptimizer = ReorderLib.fixed() ;
 
     public static final ByteOrder NetworkOrder      = ByteOrder.BIG_ENDIAN ;
+    
+    /** Unsupported (for non-standard setups) 
+     * @see #enableInlineLiterals
+     */
+    public static String propertyEnableInlineLiterals1 = 
"com.hp.hpl.jena.tdb.store.enableInlineLiterals" ;
+    /** Unsupported (for non-standard setups) 
+     * @see #enableInlineLiterals
+     */
+    public static String propertyEnableInlineLiterals2 = 
"tdb:store.enableInlineLiterals" ;
+    /** <b>Unsupported</b> (for non-standard setups).
+     * This controls whether literal values are inlined into NodeIds.
+     * This is a major efficiency boost and is the default setting.
+     * It can be set false with {@code 
-Dtdb:store.enableInlineLiterals=false}. 
+     * Do not mix databases created with this set to different values.
+     * Chaos and incorrect results will result.
+     * Use with care. No support. 
+     * Default setting is {@code true}   
+     */
+    public static final boolean enableInlineLiterals ;
+    static { // Set enableInlineLiterals from system properties.
+        Properties sysProperties = System.getProperties() ;
+        String key = null ; 
+        if ( sysProperties.containsKey(propertyEnableInlineLiterals1) )
+            key = propertyFileKey1 ;
+        else if ( sysProperties.containsKey(propertyEnableInlineLiterals2) )
+            key = propertyFileKey2 ;
+        if ( key == null )
+            enableInlineLiterals = true ;  // Normal value. 
+        else
+            enableInlineLiterals = 
Boolean.valueOf(sysProperties.getProperty(key)) ;
+    }
 
 //    public static void setNullOut(boolean nullOut)
 //    { SystemTDB.NullOut = nullOut ; }
@@ -283,10 +311,7 @@ public class SystemTDB
         { 
             log.debug("No system properties file ("+propertyFileName+")") ;
             return null ;
-        } catch (IOException ex)
-        {
-            ex.printStackTrace();
-        }
+        } catch (IOException ex) { IO.exception(ex) ; }
         return p ;
     }
 

Modified: 
jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java
URL: 
http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java?rev=1604921&r1=1604920&r2=1604921&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java 
(original)
+++ jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java 
Mon Jun 23 20:10:07 2014
@@ -29,6 +29,11 @@ import com.hp.hpl.jena.sparql.util.NodeF
 
 public class TestNodeId extends BaseTest
 {
+//    @BeforeClass public static void beforeClass() {
+//        // If running just this test suite, then this happenes before 
SystemTDB initialization.    
+//        System.getProperties().setProperty("tdb:store.enableInlineLiterals", 
"true") ;
+//    }
+    
     @Test public void nodeId_01()
     {
         NodeId nodeId = NodeId.create(37) ;


Reply via email to