jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [02/13] jena git commit: Add StoreParams arguiments to many methods. Separate out StoreParamsConst.
Date Sat, 08 Nov 2014 16:34:45 GMT
Add StoreParams arguiments to many methods.
Separate out StoreParamsConst.


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

Branch: refs/heads/master
Commit: 463de5f0451c397084bb1af2e9e4d3c17ac67c37
Parents: 140a088
Author: Andy Seaborne <andy@apache.org>
Authored: Wed Nov 5 13:43:35 2014 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Wed Nov 5 15:06:44 2014 +0000

----------------------------------------------------------------------
 .../com/hp/hpl/jena/tdb/StoreConnection.java    | 22 +++--
 .../java/com/hp/hpl/jena/tdb/TDBFactory.java    |  6 +-
 .../hpl/jena/tdb/setup/DatasetBuilderStd.java   | 12 ++-
 .../hpl/jena/tdb/setup/StoreParamsBuilder.java  | 59 +++++--------
 .../hp/hpl/jena/tdb/setup/StoreParamsCodec.java |  2 +-
 .../hp/hpl/jena/tdb/setup/StoreParamsConst.java | 87 ++++++++++++++++++++
 6 files changed, 134 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/463de5f0/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java
index 3683a29..91b333e 100644
--- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java
+++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java
@@ -27,10 +27,11 @@ import com.hp.hpl.jena.query.ReadWrite ;
 import com.hp.hpl.jena.sparql.mgt.ARQMgt ;
 import com.hp.hpl.jena.tdb.base.file.ChannelManager ;
 import com.hp.hpl.jena.tdb.base.file.Location ;
-import com.hp.hpl.jena.tdb.base.file.LocationLock;
+import com.hp.hpl.jena.tdb.base.file.LocationLock ;
 import com.hp.hpl.jena.tdb.setup.DatasetBuilderStd ;
+import com.hp.hpl.jena.tdb.setup.StoreParams ;
 import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
-import com.hp.hpl.jena.tdb.sys.SystemTDB;
+import com.hp.hpl.jena.tdb.sys.SystemTDB ;
 import com.hp.hpl.jena.tdb.transaction.* ;
 
 /** A StoreConnection is the reference to the underlying storage.
@@ -166,10 +167,10 @@ public class StoreConnection
     private static Map<Location, StoreConnection> cache = new HashMap<>() ;
 
     // ---- statics managing the cache.
-    /** Obtain a StoreConenction for a particular location */
+    /** Obtain a StoreConnection for a particular location */
     public static StoreConnection make(String location)
     {
-        return make(new Location(location)) ;
+        return make(Location.create(location)) ;
     }
 
     /** Stop managing all locations. Use with great care. */
@@ -219,17 +220,22 @@ public class StoreConnection
      * Return a StoreConnection for a particular connection. This is used to
      * create transactions for the database at the location.
      */
-    public static synchronized StoreConnection make(Location location)
+    public static synchronized StoreConnection make(Location location, StoreParams params)
     {
         StoreConnection sConn = cache.get(location) ;
         if (sConn != null) 
             return sConn ;
-        DatasetGraphTDB dsg = DatasetBuilderStd.create(location) ;
+        DatasetGraphTDB dsg = DatasetBuilderStd.create(location, params) ;
         sConn = _makeAndCache(dsg) ;
         return sConn ;
     }
 
-    /**
+    @Deprecated
+    public static StoreConnection make(Location location) {
+        return make(location, null) ;
+    }
+
+                                                    /**
      * Return the StoreConnection if one already exists for this location, else
      * return null
      */
@@ -292,7 +298,7 @@ public class StoreConnection
      */
     public static StoreConnection createMemUncached()
     {
-        DatasetGraphTDB dsg = DatasetBuilderStd.create(Location.mem()) ;
+        DatasetGraphTDB dsg = DatasetBuilderStd.create(Location.mem(), null) ;
         return new StoreConnection(dsg) ;
     }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/463de5f0/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/TDBFactory.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/TDBFactory.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/TDBFactory.java
index 5f2610e..9a01cae 100644
--- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/TDBFactory.java
+++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/TDBFactory.java
@@ -45,7 +45,7 @@ public class TDBFactory
     
     /** Create or connect to a TDB-backed dataset */ 
     public static Dataset createDataset(String dir)
-    { return createDataset(new Location(dir)) ; }
+    { return createDataset(Location.create(dir)) ; }
 
     /** Create or connect to a TDB-backed dataset */ 
     public static Dataset createDataset(Location location)
@@ -66,7 +66,7 @@ public class TDBFactory
 
     /** Create or connect to a TDB-backed dataset (graph-level) */
     public static DatasetGraph createDatasetGraph(String directory)
-    { return createDatasetGraph(new Location(directory)) ; }
+    { return createDatasetGraph(Location.create(directory)) ; }
 
     /** Create or connect to a TDB-backed dataset (graph-level) */
     public static DatasetGraph createDatasetGraph(Location location)
@@ -232,7 +232,7 @@ public class TDBFactory
     @Deprecated
     public static Graph createGraph(String dir)
     {
-        Location loc = new Location(dir) ;
+        Location loc = Location.create(dir) ;
         return createGraph(loc) ;
     }
     

http://git-wip-us.apache.org/repos/asf/jena/blob/463de5f0/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
index 3a01f60..ae903ca 100644
--- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
+++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
@@ -67,15 +67,23 @@ public class DatasetBuilderStd implements DatasetBuilder {
     private TupleIndexBuilder   tupleIndexBuilder ;
     private Recorder            recorder = null ;   
     
+    @Deprecated
     public static DatasetGraphTDB create(Location location) {
+        return create(location, null) ;
+    }
+    
+    public static DatasetGraphTDB create(Location location, StoreParams $params) {
+        if ( $params != null )
+            log.warn("StoreParams != null (ignored)") ;
         StoreParams params = paramsForLocation(location) ;
         DatasetBuilderStd x = new DatasetBuilderStd() ;
         x.standardSetup() ;
         return x.build(location, params) ;
     }
 
-    public static DatasetGraphTDB create() {
-        return create(Location.mem()) ;
+    public static DatasetGraphTDB create(StoreParams params) {
+        // Memory version?
+        return create(Location.mem(), params) ;
     }
 
     public static DatasetBuilderStd stdBuilder() {

http://git-wip-us.apache.org/repos/asf/jena/blob/463de5f0/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsBuilder.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsBuilder.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsBuilder.java
index 806fd13..0fa5d42 100644
--- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsBuilder.java
+++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsBuilder.java
@@ -19,70 +19,49 @@
 package com.hp.hpl.jena.tdb.setup;
 
 import com.hp.hpl.jena.tdb.base.block.FileMode ;
-import com.hp.hpl.jena.tdb.sys.Names ;
-import com.hp.hpl.jena.tdb.sys.SystemTDB ;
 
 public class StoreParamsBuilder {
-    // Initial values are the system defaults.
-    
+    // See also StoreParamsConst.
     /** Database and query configuration */ 
     // Key names are the base name -  encode/decode may add a prefix.
     
-    public static final String fFileMode             = "file_mode" ;
-    private FileMode           fileMode              = SystemTDB.fileMode() ;
+    private FileMode           fileMode              = StoreParamsConst.fileMode ;
 
-    public static final String fBlockReadCacheSize   = "block_read_cache_size" ;
-    private int                blockReadCacheSize    = SystemTDB.BlockReadCacheSize ;
+    private int                blockReadCacheSize    = StoreParamsConst.blockReadCacheSize
;
 
-    public static final String fBlockWriteCacheSize  = "block_write_cache_size" ;
-    private int                blockWriteCacheSize   = SystemTDB.BlockWriteCacheSize ;
+    private int                blockWriteCacheSize   = StoreParamsConst.blockWriteCacheSize
;
 
-    public static final String fNode2NodeIdCacheSize = "node2nodeid_cache_size" ;
-    private int                Node2NodeIdCacheSize  = SystemTDB.Node2NodeIdCacheSize ;
+    private int                Node2NodeIdCacheSize  = StoreParamsConst.Node2NodeIdCacheSize
;
 
-    public static final String fNodeId2NodeCacheSize = "nodeid2node_cache_size" ;
-    private int                NodeId2NodeCacheSize  = SystemTDB.NodeId2NodeCacheSize ;
+    private int                NodeId2NodeCacheSize  = StoreParamsConst.NodeId2NodeCacheSize
;
 
-    public static final String fNodeMissCacheSize    = "node_miss_cache_size" ;
-    private int                NodeMissCacheSize     = SystemTDB.NodeMissCacheSize ;
+    private int                NodeMissCacheSize     = StoreParamsConst.NodeMissCacheSize
;
 
     /** Database layout - ignored after a database is created */
 
-    public static final String fBlockSize            = "block_size" ;
-    private int                blockSize             = SystemTDB.BlockSize ;
+    private int                blockSize             = StoreParamsConst.blockSize ;
 
-    public static final String fIndexNode2Id         = "index_node2id" ;
-    private String             indexNode2Id          = Names.indexNode2Id ;
+    private String             indexNode2Id          = StoreParamsConst.indexNode2Id ;
 
-    public static final String fIndexId2Node         = "index_id2node" ;
-    private String             indexId2Node          = Names.indexId2Node ;
+    private String             indexId2Node          = StoreParamsConst.indexId2Node ;
 
-    public static final String fPrimaryIndexTriples  = "triple_index_primary" ;
-    private String             primaryIndexTriples   = Names.primaryIndexTriples ;
+    private String             primaryIndexTriples   = StoreParamsConst.primaryIndexTriples
;
 
-    public static final String fTripleIndexes        = "triple_indexes" ;
-    private String[]           tripleIndexes         = Names.tripleIndexes ;
+    private String[]           tripleIndexes         = StoreParamsConst.tripleIndexes ;
 
-    public static final String fPrimaryIndexQuads    = "quad_index_primary" ;
-    private String             primaryIndexQuads     = Names.primaryIndexQuads ;
+    private String             primaryIndexQuads     = StoreParamsConst.primaryIndexQuads
;
 
-    public static final String fQuadIndexes          = "quad_indexes" ;
-    private String[]           quadIndexes           = Names.quadIndexes ;
+    private String[]           quadIndexes           = StoreParamsConst.quadIndexes ;
 
-    public static final String fPrimaryIndexPrefix   = "prefix_index_primary" ;
-    private String             primaryIndexPrefix    = Names.primaryIndexPrefix ;
+    private String             primaryIndexPrefix    = StoreParamsConst.primaryIndexPrefix
;
 
-    public static final String fPrefixIndexes        = "prefix_indexes" ;
-    private String[]           prefixIndexes         = Names.prefixIndexes ;
+    private String[]           prefixIndexes         = StoreParamsConst.prefixIndexes ;
 
-    public static final String fIndexPrefix          = "file_prefix_index" ;
-    private String             indexPrefix           = Names.indexPrefix ;
+    private String             indexPrefix           = StoreParamsConst.indexPrefix ;
 
-    public static final String fPrefixNode2Id        = "file_prefix_nodeid" ;
-    private String             prefixNode2Id         = Names.prefixNode2Id ;
+    private String             prefixNode2Id         = StoreParamsConst.prefixNode2Id ;
 
-    public static final String fPrefixId2Node        = "file_prefix_id2node" ;
-    private String             prefixId2Node         = Names.prefixId2Node ;
+    private String             prefixId2Node         = StoreParamsConst.prefixId2Node ;
 
     public static StoreParamsBuilder create() { return new StoreParamsBuilder() ; }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/463de5f0/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsCodec.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsCodec.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsCodec.java
index b4781c4..93a8ea2 100644
--- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsCodec.java
+++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsCodec.java
@@ -26,7 +26,7 @@ import com.hp.hpl.jena.sparql.util.Utils ;
 import com.hp.hpl.jena.tdb.TDBException ;
 import com.hp.hpl.jena.tdb.base.block.FileMode ;
 
-import static com.hp.hpl.jena.tdb.setup.StoreParamsBuilder.* ;
+import static com.hp.hpl.jena.tdb.setup.StoreParamsConst.* ;
 
 /** Encode and decode {@linkplain StoreParams} */ 
 public class StoreParamsCodec {

http://git-wip-us.apache.org/repos/asf/jena/blob/463de5f0/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsConst.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsConst.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsConst.java
new file mode 100644
index 0000000..7f10450
--- /dev/null
+++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsConst.java
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.tdb.setup;
+
+import com.hp.hpl.jena.tdb.base.block.FileMode ;
+import com.hp.hpl.jena.tdb.sys.Names ;
+import com.hp.hpl.jena.tdb.sys.SystemTDB ;
+
+public class StoreParamsConst {
+    // Initial values are the system defaults.
+    
+    /** Database and query configuration */ 
+    // Key names are the base name -  encode/decode may add a prefix.
+    
+    public static final String   fFileMode             = "file_mode" ;
+    public static final FileMode fileMode              = SystemTDB.fileMode() ;
+    
+    public static final String   fBlockReadCacheSize   = "block_read_cache_size" ;
+    public static final int      blockReadCacheSize    = SystemTDB.BlockReadCacheSize ;
+    
+    public static final String   fBlockWriteCacheSize  = "block_write_cache_size" ;
+    public static final int      blockWriteCacheSize   = SystemTDB.BlockWriteCacheSize ;
+    
+    public static final String   fNode2NodeIdCacheSize = "node2nodeid_cache_size" ;
+    public static final int      Node2NodeIdCacheSize  = SystemTDB.Node2NodeIdCacheSize ;
+    
+    public static final String   fNodeId2NodeCacheSize = "nodeid2node_cache_size" ;
+    public static final int      NodeId2NodeCacheSize  = SystemTDB.NodeId2NodeCacheSize ;
+    
+    public static final String   fNodeMissCacheSize    = "node_miss_cache_size" ;
+    public static final int      NodeMissCacheSize     = SystemTDB.NodeMissCacheSize ;
+    
+    /** Database layout - ignored after a database is created */
+    public static final String   fBlockSize            = "block_size" ;
+    public static final int      blockSize             = SystemTDB.BlockSize ;
+    
+    public static final String   fIndexNode2Id         = "index_node2id" ;
+    public static final String   indexNode2Id          = Names.indexNode2Id ;
+    
+    public static final String   fIndexId2Node         = "index_id2node" ;
+    public static final String   indexId2Node          = Names.indexId2Node ;
+    
+    public static final String   fPrimaryIndexTriples  = "triple_index_primary" ;
+    public static final String   primaryIndexTriples   = Names.primaryIndexTriples ;
+    
+    public static final String   fTripleIndexes        = "triple_indexes" ;
+    public static final String[] tripleIndexes         = Names.tripleIndexes ;
+    
+    public static final String   fPrimaryIndexQuads    = "quad_index_primary" ;
+    public static final String   primaryIndexQuads     = Names.primaryIndexQuads ;
+    
+    public static final String   fQuadIndexes          = "quad_indexes" ;
+    public static final String[] quadIndexes           = Names.quadIndexes ;
+    
+    public static final String   fPrimaryIndexPrefix   = "prefix_index_primary" ;
+    public static final String   primaryIndexPrefix    = Names.primaryIndexPrefix ;
+    
+    public static final String   fPrefixIndexes        = "prefix_indexes" ;
+    public static final String[] prefixIndexes         = Names.prefixIndexes ;
+    
+    public static final String   fIndexPrefix          = "file_prefix_index" ;
+    public static final String   indexPrefix           = Names.indexPrefix ;
+    
+    public static final String   fPrefixNode2Id        = "file_prefix_nodeid" ;
+    public static final String   prefixNode2Id         = Names.prefixNode2Id ;
+    
+    public static final String   fPrefixId2Node        = "file_prefix_id2node" ;
+    public static final String   prefixId2Node         = Names.prefixId2Node ;
+    
+}
+


Mime
View raw message