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/09/07 11:44:44 UTC

svn commit: r1622992 - in /jena/trunk/jena-tdb/src: main/java/com/hp/hpl/jena/tdb/setup/ main/java/com/hp/hpl/jena/tdb/store/ main/java/com/hp/hpl/jena/tdb/sys/ test/java/com/hp/hpl/jena/tdb/graph/

Author: andy
Date: Sun Sep  7 09:44:44 2014
New Revision: 1622992

URL: http://svn.apache.org/r1622992
Log:
Clean up around DatasetPrefixesTDB

Modified:
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/B.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderBasic.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/SystemParamsBuilder.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java
    jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/TestPrefixMappingTDB.java

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/B.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/B.java?rev=1622992&r1=1622991&r2=1622992&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/B.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/B.java Sun Sep  7 09:44:44 2014
@@ -18,17 +18,15 @@
 
 package com.hp.hpl.jena.tdb.setup;
 
-import org.apache.jena.atlas.lib.NotImplemented ;
-
 import com.hp.hpl.jena.tdb.base.file.FileSet ;
 import com.hp.hpl.jena.tdb.base.record.RecordFactory ;
 import com.hp.hpl.jena.tdb.index.Index ;
 import com.hp.hpl.jena.tdb.index.IndexParams ;
-//import com.hp.hpl.jena.tdb.index.IndexBuilder ;
 import com.hp.hpl.jena.tdb.index.RangeIndex ;
 import com.hp.hpl.jena.tdb.setup.BuilderIndex.BlockMgrBuilderStd ;
 
 public class B {
+    // c.f. setupTDB
     
     public static IndexBuilder createIndexBuilderMem() { 
         return createIndexBuilder(createRangeIndexBuilderMem()) ;
@@ -50,15 +48,7 @@ public class B {
         return new BuilderIndex.RangeIndexBuilderStd(blockMgrBuilderNodes, blockMgrBuilderRecords) ;
     }
     
-    // c.f. setupTDB
-    // BlockMgrSync needed?  Outer sync?
     // XXX Merge with com.hp.hpl.jena.tdb.index.IndexFactory
-    // Two levels - with params and with (lots of) arguments for indexes, blockMgrs
-    // IndexParams
-    
-    // Rework Build.* classes first.
-    
-    //RecordFactory recordFactory = new RecordFactory(SizeOfNodeId*colMap.length(),0) ;
     
     public static RangeIndex buildRangeIndexMem(RecordFactory recordFactory) {
         FileSet fileSet = FileSet.mem() ;

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderBasic.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderBasic.java?rev=1622992&r1=1622991&r2=1622992&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderBasic.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderBasic.java Sun Sep  7 09:44:44 2014
@@ -32,6 +32,8 @@ import com.hp.hpl.jena.tdb.base.file.Loc
 import com.hp.hpl.jena.tdb.solver.OpExecutorTDB1 ;
 import com.hp.hpl.jena.tdb.store.* ;
 import com.hp.hpl.jena.tdb.store.nodetable.NodeTable ;
+import com.hp.hpl.jena.tdb.store.nodetupletable.NodeTupleTable ;
+import com.hp.hpl.jena.tdb.store.nodetupletable.NodeTupleTableConcrete ;
 import com.hp.hpl.jena.tdb.store.tupletable.TupleIndex ;
 import com.hp.hpl.jena.tdb.sys.DatasetControl ;
 import com.hp.hpl.jena.tdb.sys.DatasetControlMRSW ;
@@ -150,11 +152,11 @@ public class DatasetBuilderBasic //imple
         
         // No cache - the prefix mapping is a cache
         NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, pnId2Node, -1, -1, -1)  ;
-        
-        DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixIndexes, prefixNodes, policy) ; 
-        
+        NodeTupleTable prefixTable = new NodeTupleTableConcrete(primary.length(),
+                                                                prefixIndexes,
+                                                                prefixNodes, policy) ;
+        DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixTable) ; 
         log.debug("Prefixes: "+primary+" :: "+StrUtils.strjoin(",", indexes)) ;
-        
         return prefixes ;
     }
     

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java?rev=1622992&r1=1622991&r2=1622992&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java Sun Sep  7 09:44:44 2014
@@ -40,6 +40,8 @@ import com.hp.hpl.jena.tdb.index.IndexPa
 import com.hp.hpl.jena.tdb.solver.OpExecutorTDB1 ;
 import com.hp.hpl.jena.tdb.store.* ;
 import com.hp.hpl.jena.tdb.store.nodetable.NodeTable ;
+import com.hp.hpl.jena.tdb.store.nodetupletable.NodeTupleTable ;
+import com.hp.hpl.jena.tdb.store.nodetupletable.NodeTupleTableConcrete ;
 import com.hp.hpl.jena.tdb.store.tupletable.TupleIndex ;
 import com.hp.hpl.jena.tdb.sys.* ;
 
@@ -211,8 +213,10 @@ public class DatasetBuilderStd implement
 
         // No cache - the prefix mapping is a cache
         NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, pnId2Node, -1, -1, -1) ;
-
-        DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixIndexes, prefixNodes, policy) ;
+        NodeTupleTable prefixTable = new NodeTupleTableConcrete(primary.length(),
+                                                                prefixIndexes,
+                                                                prefixNodes, policy) ;
+        DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixTable) ;
 
         log.debug("Prefixes: " + primary + " :: " + StrUtils.strjoin(",", indexes)) ;
 
@@ -224,7 +228,7 @@ public class DatasetBuilderStd implement
     }
 
     // ======== Components level
-
+    // XXX ???
     // // This is not actually used in main dataset builder because it's done
     // inside TripleTable/QuadTable.
     // protected NodeTupleTable makeNodeTupleTable(Location location, String
@@ -242,10 +246,12 @@ public class DatasetBuilderStd implement
     // return ntt ;
     // }
 
+
+    // XXX Add params
     private TupleIndex[] makeTupleIndexes(Location location, String primary, String[] indexNames) {
         return makeTupleIndexes(location, primary, indexNames, indexNames) ;
     }
-
+    // XXX Add params
     private TupleIndex[] makeTupleIndexes(Location location, String primary, String[] indexNames, String[] filenames) {
         if ( primary.length() != 3 && primary.length() != 4 )
             error(log, "Bad primary key length: " + primary.length()) ;
@@ -258,6 +264,7 @@ public class DatasetBuilderStd implement
     }
 
     // ----
+    // XXX Add params
     protected TupleIndex makeTupleIndex(Location location, String name, String primary, String indexOrder) {
         // Commonly, name == indexOrder.
         // FileSet
@@ -267,7 +274,7 @@ public class DatasetBuilderStd implement
     }
 
     // ----
-
+    // XXX Add params
     protected NodeTable makeNodeTable(Location location, String indexNode2Id, String indexId2Node,
                                       int sizeNode2NodeIdCache, int sizeNodeId2NodeCache, int sizeNodeMissCache) {
         FileSet fsNodeToId = new FileSet(location, indexNode2Id) ;

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/SystemParamsBuilder.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/SystemParamsBuilder.java?rev=1622992&r1=1622991&r2=1622992&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/SystemParamsBuilder.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/SystemParamsBuilder.java Sun Sep  7 09:44:44 2014
@@ -41,9 +41,6 @@ public class SystemParamsBuilder {
     public static String fFileMode             = "FileMode" ;
     private FileMode     fileMode              = SystemTDB.fileMode() ;
 
-    public static String fBlockSize            = "blockSize" ;
-    private int          blockSize             = SystemTDB.BlockSize ;
-
     public static String fReadCacheSize        = "blockReadCacheSize" ;
     private int          blockReadCacheSize    = SystemTDB.BlockReadCacheSize ;
 
@@ -61,6 +58,9 @@ public class SystemParamsBuilder {
 
     /** Database layout - ignored after a database is created */
 
+    public static String fBlockSize            = "blockSize" ;
+    private int          blockSize             = SystemTDB.BlockSize ;
+
     public static String fIndexNode2Id         = "indexNode2Id" ;
     private String       indexNode2Id          = Names.indexNode2Id ;
 

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java?rev=1622992&r1=1622991&r2=1622992&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java Sun Sep  7 09:44:44 2014
@@ -21,7 +21,6 @@ package com.hp.hpl.jena.tdb.store;
 import java.util.* ;
 
 import org.apache.jena.atlas.iterator.Iter ;
-import org.apache.jena.atlas.lib.ColumnMap ;
 import org.apache.jena.atlas.lib.Tuple ;
 import org.apache.jena.atlas.logging.Log ;
 
@@ -30,98 +29,34 @@ import com.hp.hpl.jena.graph.NodeFactory
 import com.hp.hpl.jena.shared.PrefixMapping ;
 import com.hp.hpl.jena.sparql.core.DatasetPrefixStorage ;
 import com.hp.hpl.jena.sparql.graph.GraphPrefixesProjection ;
-import com.hp.hpl.jena.tdb.base.file.FileSet ;
-import com.hp.hpl.jena.tdb.base.file.Location ;
 import com.hp.hpl.jena.tdb.base.record.RecordFactory ;
-import com.hp.hpl.jena.tdb.setup.* ;
-import com.hp.hpl.jena.tdb.store.nodetable.NodeTable ;
-import com.hp.hpl.jena.tdb.store.nodetable.NodeTableFactory ;
 import com.hp.hpl.jena.tdb.store.nodetupletable.NodeTupleTable ;
-import com.hp.hpl.jena.tdb.store.nodetupletable.NodeTupleTableConcrete ;
-import com.hp.hpl.jena.tdb.store.tupletable.TupleIndex ;
-import com.hp.hpl.jena.tdb.store.tupletable.TupleIndexRecord ;
-import com.hp.hpl.jena.tdb.sys.DatasetControl ;
-import com.hp.hpl.jena.tdb.sys.DatasetControlMRSW ;
-import com.hp.hpl.jena.tdb.sys.Names ;
 
+/**
+ * Dataset prefixes; a table of nodes with prefix-centric operations. The table
+ * is G-P-U where G is a graph name ("" is used for the default graph), P is a
+ * string (the prefix) and U is the IRI.
+ */
 public class DatasetPrefixesTDB implements DatasetPrefixStorage
 {
-    // Index on GPU and a nodetable.
-    // The nodetable is itself an index and a data file.
+    /* 
+     * Almost everythig is cached in the prefix map asociated with the
+     * graph or dataset so this table is the persistent form and
+     * does nto need a cache of it's own.   
+     * 
+     */
     
     static final RecordFactory factory = new RecordFactory(3*NodeId.SIZE, 0) ;
-    static final String unamedGraphURI = "" ; //Quad.defaultGraphNode.getURI() ;
+    static final String unamedGraphURI = "" ;
     
-    // Use NodeTupleTableView?
     private final NodeTupleTable nodeTupleTable ;
     
-    /** Testing - dataset prefixes in-memory */
-    public static DatasetPrefixesTDB createTesting() { 
-        return createTesting(Location.mem(), new DatasetControlMRSW()) ;
-    }
-    
-    public static DatasetPrefixesTDB createTesting(Location location, DatasetControl policy) {
-        return new DatasetPrefixesTDB(B.createRangeIndexBuilderMem(), 
-                                      B.createIndexBuilderMem(),
-                                      location, policy) ; 
-    }
-    
-    @Deprecated
-    private DatasetPrefixesTDB(RangeIndexBuilder indexRangeBuilder, 
-                               IndexBuilder indexBuilder,
-                               Location location, DatasetControl policy)
-    {
-        SystemParams params = SystemParams.getDftSystemParams() ;
-        // TO BE REMOVED when DI sorted out.
-        // This is a table "G" "P" "U" (Graph, Prefix, URI), indexed on GPU only.
-        // GPU index
-        FileSet filesetGPU = null ;
-        if ( location != null )
-            filesetGPU = new FileSet(location, Names.indexPrefix) ;
-        
-        TupleIndex[] indexes = new TupleIndex[params.getPrefixIndexes().length] ;
-        
-        int i = 0 ;
-        for ( String indexName : params.getPrefixIndexes() ) {
-            ColumnMap colMap = new ColumnMap("GPU", params.getPrimaryIndexPrefix()) ;
-            TupleIndex index = new TupleIndexRecord(3, colMap, indexName, factory, 
-                                                    indexRangeBuilder.buildRangeIndex(filesetGPU, factory, params)) ;
-            indexes[i++] = index ;
-        }
-        
-        // Node table.
-        FileSet filesetNodeTableIdx = null ;
-        if ( location != null )
-            filesetNodeTableIdx = new FileSet(location, Names.prefixNode2Id) ;
-        
-        FileSet filesetNodeTable = null ;
-        if ( location != null )
-            filesetNodeTable = new FileSet(location, Names.prefixId2Node) ;
-        
-        SystemParamsBuilder spBuild = new SystemParamsBuilder() ;
-        spBuild.node2NodeIdCacheSize(-1) ;
-        spBuild.nodeId2NodeCacheSize(-1) ;
-        spBuild.nodeMissCacheSize(-1) ;
-        SystemParams params2 = spBuild.buildParams() ;
-        // No cache.
-        NodeTable nodes = NodeTableFactory.create(indexBuilder, filesetNodeTable, filesetNodeTableIdx, params2) ;
-        nodeTupleTable = new NodeTupleTableConcrete(3, indexes, nodes, policy) ;
+    public DatasetPrefixesTDB(NodeTupleTable nodeTupleTable) {
+        this.nodeTupleTable = nodeTupleTable ;
     }
-
-    //---- DI version
     
-    public DatasetPrefixesTDB(TupleIndex[] indexes, NodeTable nodes, DatasetControl policy)
-    {
-        this.nodeTupleTable = new NodeTupleTableConcrete(3, indexes, nodes, policy) ;
-    }
-    
-    // Use DatasetControl
-//    public boolean isReadOnly() { return nodeTupleTable.isReadOnly() ; }
-//    public void setReadOnly(boolean mode) { nodeTupleTable.setReadOnly(mode) ; }
-
     @Override
-    public synchronized void insertPrefix(String graphName, String prefix, String uri)
-    {
+    public synchronized void insertPrefix(String graphName, String prefix, String uri) {
         Node g = NodeFactory.createURI(graphName) ; 
         Node p = NodeFactory.createLiteral(prefix) ; 
         Node u = NodeFactory.createURI(uri) ;
@@ -130,8 +65,7 @@ public class DatasetPrefixesTDB implemen
     }
 
     @Override
-    public Set<String> graphNames()
-    {
+    public Set<String> graphNames() {
         Iterator<Tuple<Node>> iter = nodeTupleTable.find((Node)null, null, null) ;
         Set <String> x = new HashSet<>() ;
         for ( ; iter.hasNext() ; )
@@ -141,8 +75,7 @@ public class DatasetPrefixesTDB implemen
     }
     
     @Override
-    public synchronized String readPrefix(String graphName, String prefix)
-    {
+    public synchronized String readPrefix(String graphName, String prefix) {
         Node g = NodeFactory.createURI(graphName) ; 
         Node p = NodeFactory.createLiteral(prefix) ; 
         
@@ -157,8 +90,7 @@ public class DatasetPrefixesTDB implemen
     }
 
     @Override
-    public synchronized String readByURI(String graphName, String uriStr)
-    {
+    public synchronized String readByURI(String graphName, String uriStr) {
         Node g = NodeFactory.createURI(graphName) ; 
         Node u = NodeFactory.createURI(uriStr) ; 
         Iterator<Tuple<Node>> iter = nodeTupleTable.find(g, null, u) ;
@@ -170,13 +102,13 @@ public class DatasetPrefixesTDB implemen
     }
 
     @Override
-    public synchronized Map<String, String> readPrefixMap(String graphName)
-    {
+    public synchronized Map<String, String> readPrefixMap(String graphName) {
         Map<String, String> map = new HashMap<>() ;
         // One class of problem from mangled databases
-        // (non-trasnactional, not shutdown cleanly)
+        // (non-transactional, not shutdown cleanly)
         // ends up with NPE access the node table from
-        // prefix index. As prefixes are "nice extras"
+        // prefix index. As prefixes are "nice extras", we
+        // keep calm and carry on in th eface of exceptions.
         
         Node g = NodeFactory.createURI(graphName) ;
         Iterator<Tuple<Node>> iter = nodeTupleTable.find(g, null, null) ;
@@ -196,8 +128,7 @@ public class DatasetPrefixesTDB implemen
     }
     
     @Override
-    public synchronized void loadPrefixMapping(String graphName, PrefixMapping pmap)
-    {
+    public synchronized void loadPrefixMapping(String graphName, PrefixMapping pmap) {
         Node g = NodeFactory.createURI(graphName) ;
         Iterator<Tuple<Node>> iter = nodeTupleTable.find(g, null, null) ;
         for ( ; iter.hasNext() ; )
@@ -211,8 +142,7 @@ public class DatasetPrefixesTDB implemen
     }
     
     @Override
-    public synchronized void removeFromPrefixMap(String graphName, String prefix)
-    {
+    public synchronized void removeFromPrefixMap(String graphName, String prefix) {
         Node g = NodeFactory.createURI(graphName) ; 
         Node p = NodeFactory.createLiteral(prefix) ; 
         Iterator<Tuple<Node>> iter = nodeTupleTable.find(g, p, null) ;
@@ -231,8 +161,7 @@ public class DatasetPrefixesTDB implemen
 
     /** Return a PrefixMapping for a named graph */
     @Override
-    public PrefixMapping getPrefixMapping(String graphName)
-    { 
+    public PrefixMapping getPrefixMapping(String graphName) { 
         PrefixMapping pm = new GraphPrefixesProjection(graphName, this) ;
         // Force into cache.
         // See JENA-81
@@ -241,14 +170,12 @@ public class DatasetPrefixesTDB implemen
     }
     
     @Override
-    public void close()
-    {
+    public void close() {
         nodeTupleTable.close() ;
     }
 
     @Override
-    public void sync()
-    {
+    public void sync() {
         nodeTupleTable.sync() ;
     }
 }

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java?rev=1622992&r1=1622991&r2=1622992&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java Sun Sep  7 09:44:44 2014
@@ -41,6 +41,8 @@ import com.hp.hpl.jena.tdb.setup.Dataset
 import com.hp.hpl.jena.tdb.setup.SystemParams ;
 import com.hp.hpl.jena.tdb.store.* ;
 import com.hp.hpl.jena.tdb.store.nodetable.* ;
+import com.hp.hpl.jena.tdb.store.nodetupletable.NodeTupleTable ;
+import com.hp.hpl.jena.tdb.store.nodetupletable.NodeTupleTableConcrete ;
 import com.hp.hpl.jena.tdb.store.tupletable.TupleIndex ;
 import com.hp.hpl.jena.tdb.store.tupletable.TupleIndexRecord ;
 
@@ -119,11 +121,11 @@ public class SetupTDB
         
         // No cache - the prefix mapping is a cache
         NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, -1, pnId2Node, -1, -1)  ;
-        
-        DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixIndexes, prefixNodes, policy) ; 
-        
+        NodeTupleTable prefixTable = new NodeTupleTableConcrete(primary.length(),
+                                                                prefixIndexes,
+                                                                prefixNodes, policy) ;
+        DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixTable) ; 
         log.debug("Prefixes: "+StrUtils.strjoin(", ", indexes)) ;
-        
         return prefixes ;
     }
 

Modified: jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/TestPrefixMappingTDB.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/TestPrefixMappingTDB.java?rev=1622992&r1=1622991&r2=1622992&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/TestPrefixMappingTDB.java (original)
+++ jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/TestPrefixMappingTDB.java Sun Sep  7 09:44:44 2014
@@ -32,7 +32,9 @@ import com.hp.hpl.jena.tdb.TDB ;
 import com.hp.hpl.jena.tdb.TDBFactory ;
 import com.hp.hpl.jena.tdb.base.file.Location ;
 import com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB ;
+import com.hp.hpl.jena.tdb.sys.DatasetControl ;
 import com.hp.hpl.jena.tdb.sys.DatasetControlMRSW ;
+import com.hp.hpl.jena.tdb.sys.SetupTDB ;
 import com.hp.hpl.jena.tdb.sys.SystemTDB ;
 
 public class TestPrefixMappingTDB extends AbstractTestPrefixMapping2
@@ -47,21 +49,26 @@ public class TestPrefixMappingTDB extend
 
     
     @Override
-    protected PrefixMapping create()
-    {
-        last = DatasetPrefixesTDB.createTesting() ;
+    protected PrefixMapping create() {
+        last = createTestingMem() ;
         return view() ;
     }
 
+    static DatasetPrefixesTDB createTestingMem() { 
+        return createTesting(Location.mem(), new DatasetControlMRSW()) ;
+    }
+    
+    static DatasetPrefixesTDB createTesting(Location location, DatasetControl policy) {
+        return SetupTDB.makePrefixes(location, policy) ;
+    }
+
     @Override
-    protected PrefixMapping view()
-    {
+    protected PrefixMapping view() {
         return last.getPrefixMapping() ; 
     }
 
-    @Test public void multiple1()
-    {
-        DatasetPrefixesTDB prefixes = DatasetPrefixesTDB.createTesting() ;
+    @Test public void multiple1() {
+        DatasetPrefixesTDB prefixes = createTestingMem() ;
         PrefixMapping pmap1 = prefixes.getPrefixMapping() ;
         PrefixMapping pmap2 = prefixes.getPrefixMapping("http://graph/") ;
         pmap1.setNsPrefix("x", "http://foo/") ;
@@ -69,9 +76,8 @@ public class TestPrefixMappingTDB extend
         assertNotNull(pmap1.getNsPrefixURI("x")) ;
     }
     
-    @Test public void multiple2()
-    {
-        DatasetPrefixesTDB prefixes = DatasetPrefixesTDB.createTesting() ;
+    @Test public void multiple2() {
+        DatasetPrefixesTDB prefixes = createTestingMem() ;
         PrefixMapping pmap1 = prefixes.getPrefixMapping("http://graph/") ;  // Same
         PrefixMapping pmap2 = prefixes.getPrefixMapping("http://graph/") ;
         pmap1.setNsPrefix("x", "http://foo/") ;
@@ -80,66 +86,64 @@ public class TestPrefixMappingTDB extend
     }
     
     // Persistent.
-    @Test public void persistent1()
-    {
+    @Test
+    public void persistent1() {
         String dir = ConfigTest.getTestingDir() ;
         FileOps.clearDirectory(dir) ;
-        
-        DatasetPrefixesTDB prefixes = DatasetPrefixesTDB.createTesting(new Location(dir), new DatasetControlMRSW()) ;
+
+        DatasetPrefixesTDB prefixes = createTesting(new Location(dir), new DatasetControlMRSW()) ;
         PrefixMapping pmap1 = prefixes.getPrefixMapping() ;
-        
+
         String x = pmap1.getNsPrefixURI("x") ;
         assertNull(x) ;
-        prefixes.close();
+        prefixes.close() ;
     }
     
     // Persistent.
-    @Test public void persistent2()
-    {
+    @Test
+    public void persistent2() {
         String dir = ConfigTest.getTestingDir() ;
         FileOps.clearDirectory(dir) ;
-        
-        DatasetPrefixesTDB prefixes = DatasetPrefixesTDB.createTesting(new Location(dir), new DatasetControlMRSW()) ;
+
+        DatasetPrefixesTDB prefixes = createTesting(new Location(dir), new DatasetControlMRSW()) ;
         PrefixMapping pmap1 = prefixes.getPrefixMapping() ;
-        
+
         pmap1.setNsPrefix("x", "http://foo/") ;
         prefixes.close() ;
-        
-        prefixes = DatasetPrefixesTDB.createTesting(new Location(dir), new DatasetControlMRSW()) ;
+
+        prefixes = createTesting(new Location(dir), new DatasetControlMRSW()) ;
         assertEquals("http://foo/", pmap1.getNsPrefixURI("x")) ;
-        prefixes.close();
+        prefixes.close() ;
     }
     
-    @Test public void persistent3()
-    {
+    @Test
+    public void persistent3() {
         // Test case from a report by Holger Knublauch
-        if ( false )
-        {
-            //TDB.getContext().set(SystemTDB.symFileMode, "mapped") ;
+        if ( false ) {
+            // TDB.getContext().set(SystemTDB.symFileMode, "mapped") ;
             TDB.getContext().set(SystemTDB.symFileMode, "direct") ;
         }
         String DB = ConfigTest.getCleanDir() ;
         {
             // Create new DB (assuming it's empty now)
             Graph graph = TDBFactory.createDatasetGraph(DB).getDefaultGraph() ;
-            PrefixMapping pm = graph.getPrefixMapping();
-            pm.setNsPrefix("test", "http://test");
-            graph.close();
+            PrefixMapping pm = graph.getPrefixMapping() ;
+            pm.setNsPrefix("test", "http://test") ;
+            graph.close() ;
         }
 
         {
             // Reconnect to the same DB
             Graph graph = TDBFactory.createDatasetGraph(DB).getDefaultGraph() ;
-            PrefixMapping pm = graph.getPrefixMapping();
-            Map<String, String> map = pm.getNsPrefixMap();
+            PrefixMapping pm = graph.getPrefixMapping() ;
+            Map<String, String> map = pm.getNsPrefixMap() ;
             assertEquals(1, map.size()) ;
-            //System.out.println("Size: " + map.size());
-            String ns = pm.getNsPrefixURI("test");
-            //System.out.println("Namespace: " + ns);
+            // System.out.println("Size: " + map.size());
+            String ns = pm.getNsPrefixURI("test") ;
+            // System.out.println("Namespace: " + ns);
             assertEquals("http://test", ns) ;
-            graph.close();
+            graph.close() ;
         }
-        FileOps.deleteSilent(DB);
-
+        FileOps.deleteSilent(DB) ;
     }
 }