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 2017/10/03 19:33:59 UTC
[13/65] [abbrv] jena git commit: JENA-1397: Rename java packages
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/ComponentIdMgr.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/ComponentIdMgr.java b/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/ComponentIdMgr.java
deleted file mode 100644
index a6dd85d..0000000
--- a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/ComponentIdMgr.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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 org.seaborne.tdb2.setup;
-
-import java.util.HashMap ;
-import java.util.Map ;
-import java.util.UUID ;
-
-import org.seaborne.dboe.transaction.txn.ComponentId ;
-import org.slf4j.Logger ;
-import org.slf4j.LoggerFactory ;
-
-// Consistent name -> ComponentId
-
-public class ComponentIdMgr {
- private static Logger log = LoggerFactory.getLogger(ComponentIdMgr.class) ;
-
- private static Map<String, Integer> names = new HashMap<>() ;
- static {
- // Well know names.
- setup(1, "SPO") ;
- setup(2, "POS") ;
- setup(3, "PSO") ;
- setup(4, "OSP") ;
-
- setup(11, "GSPO") ;
- setup(12, "GPOS") ;
- setup(13, "GPSO") ;
- setup(14, "GOSP") ;
-
- setup(21, "POSG") ;
- setup(22, "PSOG") ;
- setup(23, "OSPG") ;
- setup(24, "SPOG") ;
-
- setup(30, "GPU") ;
-
- setup(40, "prefixes") ;
- setup(41, "prefixes-data") ;
-
- setup(50, "nodes") ;
- setup(51, "nodes-data") ;
- }
-
- static void setup(int idx, String unitName) {
- if ( names.containsKey(unitName) )
- log.error("Name '"+unitName+"' is already registered") ;
- names.put(unitName, idx) ;
- }
-
- private Map<String, ComponentId> allocated = new HashMap<>() ;
-
- // Name to index mapping.
- static Map<String, String> mapper = new HashMap<>() ;
- private final UUID base ;
-
- public ComponentIdMgr(UUID base) {
- this.base = base ;
- }
-
- public static int getIndex(String name) {
- Integer idx = names.get(name) ;
- if ( idx == null ) {
- log.error("Unregistered '"+name+"'") ;
- return -1 ;
- }
- return idx ;
- }
-
- public ComponentId getComponentId(String name) {
-// // Trace duplicates
-// final String tracename = "SPO" ;
-// if ( tracename.equals(name) )
-// log.info("Name '"+name+"'") ;
- if ( ! names.containsKey(name))
- log.error("Name '"+name+"' is not registered") ;
- if ( allocated.containsKey(name) ) {
- log.error("ComponentId for '"+name+"' has already been allocated") ;
- return allocated.get(name) ;
- }
- ComponentId cid = ComponentId.alloc(name, base, names.get(name)) ;
- allocated.put(name, cid) ;
- return cid ;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParams.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParams.java b/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParams.java
deleted file mode 100644
index 94b8893..0000000
--- a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParams.java
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
- * 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 org.seaborne.tdb2.setup;
-
-import java.util.Objects ;
-
-import org.seaborne.dboe.base.block.FileMode ;
-import org.seaborne.dboe.index.IndexParams ;
-import org.seaborne.tdb2.setup.StoreParamsBuilder.Item ;
-
-/** System parameters for a TDB database instance.
- * <p>
- * Some parameters can be changed from run to run
- * and some parameters can only be changed at the point the database is
- * created.
- * <p>
- * Getting paramters settings wrong can destroy a databse.
- * Alternating the block size is not encouraged and should only be
- * done if necessary. It can silently destroy a database if set
- * to a different value than thatused to create the database. The
- * default value of 8Kbytes is good for almost use.
- *
- * @see StoreParamsBuilder for constructing StoreParams
- * @see StoreParamsConst for default values.
- */
-public class StoreParams implements IndexParams, StoreParamsDynamic
-{
- /* These are items you can change JVM to JVM */
-
- /*package*/ final Item<FileMode> fileMode ;
- /*package*/ final Item<Integer> blockSize ;
- /*package*/ final Item<Integer> blockReadCacheSize ;
- /*package*/ final Item<Integer> blockWriteCacheSize ;
- /*package*/ final Item<Integer> Node2NodeIdCacheSize ;
- /*package*/ final Item<Integer> NodeId2NodeCacheSize ;
- /*package*/ final Item<Integer> NodeMissCacheSize ;
-
- /* These are items affect database layout and
- * only can be applied when a database is created.
- * They do not affect existing databases.
- * If you want to, say, change the index structure,
- * you'll need to use the index tools.
- */
-
- /*package*/ final Item<String> nodeTableBaseName ;
-
- /*package*/ final Item<String> primaryIndexTriples ;
- /*package*/ final Item<String[]> tripleIndexes ;
-
- /*package*/ final Item<String> primaryIndexQuads ;
- /*package*/ final Item<String[]> quadIndexes ;
-
- /*package*/ final Item<String> prefixTableBaseName ;
- /*package*/ final Item<String> primaryIndexPrefix ;
- /*package*/ final Item<String[]> prefixIndexes ;
-
- /** Build StoreParams, starting from system defaults.
- *
- * @return StoreParamsBuilder
- */
- public static StoreParamsBuilder builder() { return StoreParamsBuilder.create() ; }
-
- /** Build StoreParams, starting from given default values.
- *
- * @return StoreParamsBuilder
- */
- public static StoreParamsBuilder builder(StoreParams params) { return StoreParamsBuilder.create(params) ; }
-
- /*package*/ StoreParams(Item<FileMode> fileMode, Item<Integer> blockSize,
- Item<Integer> blockReadCacheSize, Item<Integer> blockWriteCacheSize,
- Item<Integer> node2NodeIdCacheSize, Item<Integer> nodeId2NodeCacheSize,
- Item<Integer> nodeMissCacheSize,
-
- Item<String> nodeTableBaseName,
- Item<String> primaryIndexTriples, Item<String[]> tripleIndexes,
- Item<String> primaryIndexQuads, Item<String[]> quadIndexes,
-
- Item<String> prefixTableBasename,
- Item<String> primaryIndexPrefix, Item<String[]> prefixIndexes) {
- this.fileMode = fileMode ;
- this.blockSize = blockSize ;
- this.blockReadCacheSize = blockReadCacheSize ;
- this.blockWriteCacheSize = blockWriteCacheSize ;
- this.Node2NodeIdCacheSize = node2NodeIdCacheSize ;
- this.NodeId2NodeCacheSize = nodeId2NodeCacheSize ;
- this.NodeMissCacheSize = nodeMissCacheSize ;
-
- this.nodeTableBaseName = nodeTableBaseName ;
-
- this.primaryIndexTriples = primaryIndexTriples ;
- this.tripleIndexes = tripleIndexes ;
- this.primaryIndexQuads = primaryIndexQuads ;
- this.quadIndexes = quadIndexes ;
- this.primaryIndexPrefix = primaryIndexPrefix ;
- this.prefixIndexes = prefixIndexes ;
-
- this.prefixTableBaseName = prefixTableBasename ;
- }
-
- /** The system default settings. This is the normal set to use.
- * It is the set of values used when no StoreParams is provided,
- * which is the normal usage.
- */
- public static StoreParams getDftStoreParams() {
- return StoreParamsConst.dftStoreParams ;
- }
-
- /** A {@code StoreParams} that provides a smaller
- * in-JVM foot print. This is compatible with
- * any database but it it is wise to use this consistently,
- * that is, use when created and when opened later.
- * It reduces cache sizes and runs the database in "direct"
- * file mode so as not to use memory mapped files
- * in addition to the JVM space.
- */
- public static StoreParams getSmallStoreParams() {
- return StoreParamsConst.smallStoreParams ;
- }
-
- @Override
- public FileMode getFileMode() {
- return fileMode.value ;
- }
-
- @Override
- public boolean isSetFileMode() {
- return fileMode.isSet ;
- }
-
- @Override
- public Integer getBlockSize() {
- return blockSize.value ;
- }
-
- @Override
- public Integer getBlockReadCacheSize() {
- return blockReadCacheSize.value ;
- }
-
- @Override
- public boolean isSetBlockReadCacheSize() {
- return blockReadCacheSize.isSet ;
- }
-
- @Override
- public Integer getBlockWriteCacheSize() {
- return blockWriteCacheSize.value ;
- }
-
- @Override
- public boolean isSetBlockWriteCacheSize() {
- return blockWriteCacheSize.isSet ;
- }
-
- @Override
- public Integer getNode2NodeIdCacheSize() {
- return Node2NodeIdCacheSize.value ;
- }
-
- @Override
- public boolean isSetNodeId2NodeCacheSize() {
- return NodeId2NodeCacheSize.isSet ;
- }
-
- @Override
- public boolean isSetNode2NodeIdCacheSize() {
- return Node2NodeIdCacheSize.isSet ;
- }
-
- @Override
- public Integer getNodeId2NodeCacheSize() {
- return NodeId2NodeCacheSize.value ;
- }
-
- @Override
- public Integer getNodeMissCacheSize() {
- return NodeMissCacheSize.value ;
- }
-
- @Override
- public boolean isSetNodeMissCacheSize() {
- return NodeMissCacheSize.isSet ;
- }
-
- public String getNodeTableBaseName() {
- return nodeTableBaseName.value ;
- }
-
- public boolean isSetNodeTableBaseName() {
- return nodeTableBaseName.isSet ;
- }
-
- public String getPrimaryIndexTriples() {
- return primaryIndexTriples.value ;
- }
-
- public String[] getTripleIndexes() {
- return tripleIndexes.value ;
- }
-
- public String getPrimaryIndexQuads() {
- return primaryIndexQuads.value ;
- }
-
- public String[] getQuadIndexes() {
- return quadIndexes.value ;
- }
-
- public String getPrefixTableBaseName() {
- return prefixTableBaseName.value ;
- }
-
- public boolean isSetPrefixBaseName() {
- return prefixTableBaseName.isSet ;
- }
-
-
-
- public String getPrimaryIndexPrefix() {
- return primaryIndexPrefix.value ;
- }
-
- public String[] getPrefixIndexes() {
- return prefixIndexes.value ;
- }
-
- @Override
- public String toString() {
- StringBuilder buff = new StringBuilder() ;
- fmt(buff, "fileMode", getFileMode().toString(), fileMode.isSet) ;
- fmt(buff, "blockSize", getBlockSize(), blockSize.isSet) ;
- fmt(buff, "readCacheSize", getBlockReadCacheSize(), blockReadCacheSize.isSet) ;
- fmt(buff, "writeCacheSize", getBlockWriteCacheSize(), blockWriteCacheSize.isSet) ;
- fmt(buff, "Node2NodeIdCacheSize", getNode2NodeIdCacheSize(), Node2NodeIdCacheSize.isSet) ;
- fmt(buff, "NodeId2NodeCacheSize", getNodeId2NodeCacheSize(), NodeId2NodeCacheSize.isSet) ;
- fmt(buff, "NodeMissCacheSize", getNodeMissCacheSize(), NodeMissCacheSize.isSet) ;
-
- fmt(buff, "nodeTableBaseName", getNodeTableBaseName(), nodeTableBaseName.isSet) ;
- fmt(buff, "primaryIndexTriples", getPrimaryIndexTriples(), primaryIndexTriples.isSet) ;
- fmt(buff, "tripleIndexes", getTripleIndexes(), tripleIndexes.isSet) ;
- fmt(buff, "primaryIndexQuads", getPrimaryIndexQuads(), primaryIndexQuads.isSet) ;
- fmt(buff, "quadIndexes", getQuadIndexes(), quadIndexes.isSet) ;
-
- fmt(buff, "prefixTableBaseName", getPrefixTableBaseName(), prefixTableBaseName.isSet) ;
- fmt(buff, "primaryIndexPrefix", getPrimaryIndexPrefix(), primaryIndexPrefix.isSet) ;
- fmt(buff, "prefixIndexes", getPrefixIndexes(), prefixIndexes.isSet) ;
-
- return buff.toString() ;
- }
-
- private void fmt(StringBuilder buff, String name, String[] strings, boolean isSet) {
- String dftStr = "" ;
- if ( ! isSet )
- dftStr = "dft:" ;
- buff.append(String.format("%-20s %s[%s]\n", name, dftStr, String.join(", ", strings))) ;
- }
-
- private void fmt(StringBuilder buff, String name, String value, boolean isSet) {
- String dftStr = "" ;
- if ( ! isSet )
- dftStr = "dft:" ;
- buff.append(String.format("%-20s %s%s\n", name, dftStr, value)) ;
- }
-
- private void fmt(StringBuilder buff, String name, int value, boolean isSet) {
- String dftStr = "" ;
- if ( ! isSet )
- dftStr = "dft:" ;
- buff.append(String.format("%-20s %s%s\n", name, dftStr, value)) ;
- }
-
- /** Equality but ignore "isSet" */
- public static boolean sameValues(StoreParams params1, StoreParams params2) {
- if ( params1 == null && params2 == null )
- return true ;
- if ( params1 == null )
- return false ;
- if ( params2 == null )
- return false ;
- if ( !sameValues(params1.fileMode, params2.fileMode) )
- return false ;
- if ( !sameValues(params1.blockSize, params2.blockSize) )
- return false ;
- if ( !sameValues(params1.blockReadCacheSize, params2.blockReadCacheSize) )
- return false ;
- if ( !sameValues(params1.blockWriteCacheSize, params2.blockWriteCacheSize) )
- return false ;
- if ( !sameValues(params1.Node2NodeIdCacheSize, params2.Node2NodeIdCacheSize) )
- return false ;
- if ( !sameValues(params1.NodeId2NodeCacheSize, params2.NodeId2NodeCacheSize) )
- return false ;
- if ( !sameValues(params1.NodeMissCacheSize, params2.NodeMissCacheSize) )
- return false ;
- if ( !sameValues(params1.nodeTableBaseName, params2.nodeTableBaseName) )
- return false ;
- if ( !sameValues(params1.primaryIndexTriples, params2.primaryIndexTriples) )
- return false ;
- if ( !sameValues(params1.tripleIndexes, params2.tripleIndexes) )
- return false ;
- if ( !sameValues(params1.primaryIndexQuads, params2.primaryIndexQuads) )
- return false ;
- if ( !sameValues(params1.quadIndexes, params2.quadIndexes) )
- return false ;
- if ( !sameValues(params1.prefixTableBaseName, params2.prefixTableBaseName) )
- return false ;
- if ( !sameValues(params1.primaryIndexPrefix, params2.primaryIndexPrefix) )
- return false ;
- if ( !sameValues(params1.prefixIndexes, params2.prefixIndexes) )
- return false ;
- return true ;
- }
-
- private static <X> boolean sameValues(Item<X> item1, Item<X> item2) {
- return Objects.deepEquals(item1.value, item2.value) ;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31 ;
- int result = 1 ;
- result = prime * result + ((Node2NodeIdCacheSize == null) ? 0 : Node2NodeIdCacheSize.hashCode()) ;
- result = prime * result + ((NodeId2NodeCacheSize == null) ? 0 : NodeId2NodeCacheSize.hashCode()) ;
- result = prime * result + ((NodeMissCacheSize == null) ? 0 : NodeMissCacheSize.hashCode()) ;
- result = prime * result + ((blockReadCacheSize == null) ? 0 : blockReadCacheSize.hashCode()) ;
- result = prime * result + ((blockSize == null) ? 0 : blockSize.hashCode()) ;
- result = prime * result + ((blockWriteCacheSize == null) ? 0 : blockWriteCacheSize.hashCode()) ;
- result = prime * result + ((fileMode == null) ? 0 : fileMode.hashCode()) ;
- result = prime * result + ((nodeTableBaseName == null) ? 0 : nodeTableBaseName.hashCode()) ;
- result = prime * result + ((prefixTableBaseName == null) ? 0 : prefixTableBaseName.hashCode()) ;
- result = prime * result + ((prefixIndexes == null) ? 0 : prefixIndexes.hashCode()) ;
- result = prime * result + ((primaryIndexPrefix == null) ? 0 : primaryIndexPrefix.hashCode()) ;
- result = prime * result + ((primaryIndexQuads == null) ? 0 : primaryIndexQuads.hashCode()) ;
- result = prime * result + ((primaryIndexTriples == null) ? 0 : primaryIndexTriples.hashCode()) ;
- result = prime * result + ((quadIndexes == null) ? 0 : quadIndexes.hashCode()) ;
- result = prime * result + ((tripleIndexes == null) ? 0 : tripleIndexes.hashCode()) ;
- return result ;
- }
-
- @Override
- public boolean equals(Object obj) {
- if ( this == obj )
- return true ;
- if ( obj == null )
- return false ;
- if ( getClass() != obj.getClass() )
- return false ;
- StoreParams other = (StoreParams)obj ;
- if ( Node2NodeIdCacheSize == null ) {
- if ( other.Node2NodeIdCacheSize != null )
- return false ;
- } else if ( !Node2NodeIdCacheSize.equals(other.Node2NodeIdCacheSize) )
- return false ;
- if ( NodeId2NodeCacheSize == null ) {
- if ( other.NodeId2NodeCacheSize != null )
- return false ;
- } else if ( !NodeId2NodeCacheSize.equals(other.NodeId2NodeCacheSize) )
- return false ;
- if ( NodeMissCacheSize == null ) {
- if ( other.NodeMissCacheSize != null )
- return false ;
- } else if ( !NodeMissCacheSize.equals(other.NodeMissCacheSize) )
- return false ;
- if ( blockReadCacheSize == null ) {
- if ( other.blockReadCacheSize != null )
- return false ;
- } else if ( !blockReadCacheSize.equals(other.blockReadCacheSize) )
- return false ;
- if ( blockSize == null ) {
- if ( other.blockSize != null )
- return false ;
- } else if ( !blockSize.equals(other.blockSize) )
- return false ;
- if ( blockWriteCacheSize == null ) {
- if ( other.blockWriteCacheSize != null )
- return false ;
- } else if ( !blockWriteCacheSize.equals(other.blockWriteCacheSize) )
- return false ;
- if ( fileMode == null ) {
- if ( other.fileMode != null )
- return false ;
- } else if ( !fileMode.equals(other.fileMode) )
- return false ;
- if ( nodeTableBaseName == null ) {
- if ( other.nodeTableBaseName != null )
- return false ;
- } else if ( !nodeTableBaseName.equals(other.nodeTableBaseName) )
- return false ;
- if ( prefixTableBaseName == null ) {
- if ( other.prefixTableBaseName != null )
- return false ;
- } else if ( !prefixTableBaseName.equals(other.prefixTableBaseName) )
- return false ;
- if ( prefixIndexes == null ) {
- if ( other.prefixIndexes != null )
- return false ;
- } else if ( !prefixIndexes.equals(other.prefixIndexes) )
- return false ;
- if ( primaryIndexPrefix == null ) {
- if ( other.primaryIndexPrefix != null )
- return false ;
- } else if ( !primaryIndexPrefix.equals(other.primaryIndexPrefix) )
- return false ;
- if ( primaryIndexQuads == null ) {
- if ( other.primaryIndexQuads != null )
- return false ;
- } else if ( !primaryIndexQuads.equals(other.primaryIndexQuads) )
- return false ;
- if ( primaryIndexTriples == null ) {
- if ( other.primaryIndexTriples != null )
- return false ;
- } else if ( !primaryIndexTriples.equals(other.primaryIndexTriples) )
- return false ;
- if ( quadIndexes == null ) {
- if ( other.quadIndexes != null )
- return false ;
- } else if ( !quadIndexes.equals(other.quadIndexes) )
- return false ;
- if ( tripleIndexes == null ) {
- if ( other.tripleIndexes != null )
- return false ;
- } else if ( !tripleIndexes.equals(other.tripleIndexes) )
- return false ;
- return true ;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsBuilder.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsBuilder.java b/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsBuilder.java
deleted file mode 100644
index aa866d4..0000000
--- a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsBuilder.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * 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 org.seaborne.tdb2.setup;
-
-import org.seaborne.dboe.base.block.FileMode ;
-
-public class StoreParamsBuilder {
- // Immutable.
- static class Item<X> {
- final X value ;
- final boolean isSet ;
-
- Item(X value, boolean isSet) {
- this.value = value ;
- this.isSet = isSet ;
- }
- @Override
- public int hashCode() {
- final int prime = 31 ;
- int result = 1 ;
- result = prime * result + (isSet ? 1231 : 1237) ;
- result = prime * result + ((value == null) ? 0 : value.hashCode()) ;
- return result ;
- }
- @Override
- public boolean equals(Object obj) {
- if ( this == obj )
- return true ;
- if ( obj == null )
- return false ;
- if ( getClass() != obj.getClass() )
- return false ;
- Item<?> other = (Item<?>)obj ;
- if ( isSet != other.isSet )
- return false ;
- if ( value == null ) {
- if ( other.value != null )
- return false ;
- } else if ( !value.equals(other.value) )
- return false ;
- return true ;
- }
- }
-
- // See also StoreParamsConst.
- /** Database and query configuration */
- // Key names are the base name - encode/decode may add a prefix.
-
- private Item<FileMode> fileMode = new Item<>(StoreParamsConst.fileMode, false) ;
-
- private Item<Integer> blockReadCacheSize = new Item<>(StoreParamsConst.blockReadCacheSize, false) ;
-
- private Item<Integer> blockWriteCacheSize = new Item<>(StoreParamsConst.blockWriteCacheSize, false) ;
-
- private Item<Integer> Node2NodeIdCacheSize = new Item<>(StoreParamsConst.Node2NodeIdCacheSize, false) ;
-
- private Item<Integer> NodeId2NodeCacheSize = new Item<>(StoreParamsConst.NodeId2NodeCacheSize, false) ;
-
- private Item<Integer> NodeMissCacheSize = new Item<>(StoreParamsConst.NodeMissCacheSize, false) ;
-
- /** Database layout - ignored after a database is created */
-
- private Item<Integer> blockSize = new Item<>(StoreParamsConst.blockSize, false) ;
-
- private Item<String> nodeTableBaseName = new Item<>(StoreParamsConst.nodeTableBaseName, false) ;
-
- private Item<String> primaryIndexTriples = new Item<>(StoreParamsConst.primaryIndexTriples, false) ;
-
- private Item<String[]> tripleIndexes = new Item<>(StoreParamsConst.tripleIndexes, false) ;
-
- private Item<String> primaryIndexQuads = new Item<>(StoreParamsConst.primaryIndexQuads, false) ;
-
- private Item<String[]> quadIndexes = new Item<>(StoreParamsConst.quadIndexes, false) ;
-
- private Item<String> prefixTableBaseName = new Item<>(StoreParamsConst.prefixTableBaseName, false) ;
-
- private Item<String> primaryIndexPrefix = new Item<>(StoreParamsConst.primaryIndexPrefix, false) ;
-
- private Item<String[]> prefixIndexes = new Item<>(StoreParamsConst.prefixIndexes, false) ;
-
- public static StoreParamsBuilder create() {
- return new StoreParamsBuilder() ;
- }
-
- public static StoreParamsBuilder create(StoreParams params) {
- return new StoreParamsBuilder(params) ;
- }
-
- /** Using a base set of {@link StoreParams}, and update with dynamic parameters.
- *
- * @param baseParams
- * @param additionalParams
- * @return StoreParams
- */
-
- public static StoreParams modify(StoreParams baseParams, StoreParamsDynamic additionalParams) {
- StoreParamsBuilder b = new StoreParamsBuilder(baseParams) ;
- // Merge explicitly set params
- if ( additionalParams.isSetFileMode() )
- b.fileMode(additionalParams.getFileMode()) ;
-
- if ( additionalParams.isSetBlockReadCacheSize() )
- b.blockReadCacheSize(additionalParams.getBlockReadCacheSize()) ;
-
- if ( additionalParams.isSetBlockWriteCacheSize() )
- b.blockWriteCacheSize(additionalParams.getBlockWriteCacheSize()) ;
-
- if ( additionalParams.isSetNode2NodeIdCacheSize() )
- b.node2NodeIdCacheSize(additionalParams.getNode2NodeIdCacheSize()) ;
-
- if ( additionalParams.isSetNodeId2NodeCacheSize() )
- b.nodeId2NodeCacheSize(additionalParams.getNodeId2NodeCacheSize()) ;
-
- if ( additionalParams.isSetNodeMissCacheSize() )
- b.nodeMissCacheSize(additionalParams.getNodeMissCacheSize()) ;
-
- return b.build();
- }
-
-
- private StoreParamsBuilder() {}
-
- /** Initial with a StoreParams as default values */
- private StoreParamsBuilder(StoreParams other) {
- this.fileMode = other.fileMode ;
- this.blockSize = other.blockSize ;
- this.blockReadCacheSize = other.blockReadCacheSize ;
- this.blockWriteCacheSize = other.blockWriteCacheSize ;
- this.Node2NodeIdCacheSize = other.Node2NodeIdCacheSize ;
- this.NodeId2NodeCacheSize = other.NodeId2NodeCacheSize ;
- this.NodeMissCacheSize = other.NodeMissCacheSize ;
-
- this.nodeTableBaseName = other.nodeTableBaseName ;
-
- this.primaryIndexTriples = other.primaryIndexTriples ;
- this.tripleIndexes = other.tripleIndexes ;
-
- this.primaryIndexQuads = other.primaryIndexQuads ;
- this.quadIndexes = other.quadIndexes ;
-
- this.prefixTableBaseName = other.prefixTableBaseName ;
- this.primaryIndexPrefix = other.primaryIndexPrefix ;
- this.prefixIndexes = other.prefixIndexes ;
- }
-
- public StoreParams build() {
- return new StoreParams(
- fileMode, blockSize, blockReadCacheSize, blockWriteCacheSize,
- Node2NodeIdCacheSize, NodeId2NodeCacheSize, NodeMissCacheSize,
- nodeTableBaseName,
- primaryIndexTriples, tripleIndexes,
- primaryIndexQuads, quadIndexes,
- prefixTableBaseName, primaryIndexPrefix,
- prefixIndexes) ;
- }
-
- public FileMode getFileMode() {
- return fileMode.value ;
- }
-
- public StoreParamsBuilder fileMode(FileMode fileMode) {
- this.fileMode = new Item<>(fileMode, true) ;
- return this ;
- }
-
- public int getBlockSize() {
- return blockSize.value ;
- }
-
- public StoreParamsBuilder blockSize(int blockSize) {
- this.blockSize = new Item<>(blockSize, true) ;
- return this ;
- }
-
- public int getBlockReadCacheSize() {
- return blockReadCacheSize.value ;
- }
-
- public StoreParamsBuilder blockReadCacheSize(int blockReadCacheSize) {
- this.blockReadCacheSize = new Item<>(blockReadCacheSize, true) ;
- return this ;
- }
-
- public int getBlockWriteCacheSize() {
- return blockWriteCacheSize.value ;
- }
-
- public StoreParamsBuilder blockWriteCacheSize(int blockWriteCacheSize) {
- this.blockWriteCacheSize = new Item<>(blockWriteCacheSize, true) ;
- return this ;
- }
-
- public int getNode2NodeIdCacheSize() {
- return Node2NodeIdCacheSize.value ;
- }
-
- public StoreParamsBuilder node2NodeIdCacheSize(int node2NodeIdCacheSize) {
- Node2NodeIdCacheSize = new Item<>(node2NodeIdCacheSize, true) ;
- return this ;
- }
-
- public int getNodeId2NodeCacheSize() {
- return NodeId2NodeCacheSize.value ;
- }
-
- public StoreParamsBuilder nodeId2NodeCacheSize(int nodeId2NodeCacheSize) {
- NodeId2NodeCacheSize = new Item<>(nodeId2NodeCacheSize, true) ;
- return this ;
- }
-
- public int getNodeMissCacheSize() {
- return NodeMissCacheSize.value ;
- }
-
- public StoreParamsBuilder nodeMissCacheSize(int nodeMissCacheSize) {
- NodeMissCacheSize = new Item<>(nodeMissCacheSize, true) ;
- return this ;
- }
-
- public String getNodeTableBaseName() {
- return nodeTableBaseName.value ;
- }
-
- public StoreParamsBuilder nodeTableBaseName(String nodeTableBaseName) {
- this.nodeTableBaseName = new Item<>(nodeTableBaseName, true);
- return this ;
- }
-
- public String getPrimaryIndexTriples() {
- return primaryIndexTriples.value ;
- }
-
- public StoreParamsBuilder primaryIndexTriples(String primaryIndexTriples) {
- this.primaryIndexTriples = new Item<>(primaryIndexTriples, true) ;
- return this ;
- }
-
- public String[] getTripleIndexes() {
- return tripleIndexes.value ;
- }
-
- public StoreParamsBuilder tripleIndexes(String[] tripleIndexes) {
- this.tripleIndexes = new Item<>(tripleIndexes, true) ;
- return this ;
- }
-
- public String getPrimaryIndexQuads() {
- return primaryIndexQuads.value ;
- }
-
- public StoreParamsBuilder primaryIndexQuads(String primaryIndexQuads) {
- this.primaryIndexQuads = new Item<>(primaryIndexQuads, true) ;
- return this ;
- }
-
- public String[] getQuadIndexes() {
- return quadIndexes.value ;
- }
-
- public StoreParamsBuilder quadIndexes(String[] quadIndexes) {
- this.quadIndexes = new Item<>(quadIndexes, true) ;
- return this ;
- }
-
-
- public String getPreifixTableBaseName() {
- return prefixTableBaseName.value ;
- }
-
- public StoreParamsBuilder prefixTableBaseName(String prefixTableBaseName) {
- this.prefixTableBaseName = new Item<>(prefixTableBaseName, true) ;
- return this ;
- }
-
- public String getPrimaryIndexPrefix() {
- return primaryIndexPrefix.value ;
- }
-
- public StoreParamsBuilder primaryIndexPrefix(String primaryIndexPrefix) {
- this.primaryIndexPrefix = new Item<>(primaryIndexPrefix, true) ;
- return this ;
- }
-
- public String[] getPrefixIndexes() {
- return prefixIndexes.value ;
- }
-
- public StoreParamsBuilder prefixIndexes(String[] prefixIndexes) {
- this.prefixIndexes = new Item<>(prefixIndexes, true) ;
- return this ;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsCodec.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsCodec.java b/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsCodec.java
deleted file mode 100644
index a2881f3..0000000
--- a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsCodec.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * 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 org.seaborne.tdb2.setup;
-
-import static org.seaborne.tdb2.setup.StoreParamsConst.* ;
-
-import java.io.BufferedOutputStream ;
-import java.io.FileOutputStream ;
-import java.io.IOException ;
-import java.io.OutputStream ;
-
-import org.apache.jena.atlas.AtlasException ;
-import org.apache.jena.atlas.io.IO ;
-import org.apache.jena.atlas.json.* ;
-import org.apache.jena.atlas.lib.Lib ;
-import org.seaborne.dboe.base.block.FileMode ;
-import org.seaborne.dboe.base.file.Location ;
-import org.seaborne.dboe.sys.Names;
-import org.seaborne.tdb2.TDBException ;
-
-/** Encode and decode {@link StoreParams} */
-public class StoreParamsCodec {
-
- /** Write to a file */
- public static void write(Location location, StoreParams params) {
- write(location.getPath(Names.TDB_CONFIG_FILE) ,params) ;
- }
-
- /** Write to a file */
- public static void write(String filename, StoreParams params) {
- try (OutputStream out = new FileOutputStream(filename);
- OutputStream out2 = new BufferedOutputStream(out); ) {
- JsonObject object = encodeToJson(params) ;
- JSON.write(out2, object) ;
- out2.write('\n') ;
- }
- catch (IOException ex) { IO.exception(ex); }
- }
-
- /** Read from a file */
- public static StoreParams read(Location location) {
- return read(location.getPath(Names.TDB_CONFIG_FILE)) ;
- }
-
- /** Read from a file, if possible. */
- public static StoreParams read(String filename) {
- try {
- JsonObject obj = JSON.read(filename) ;
- return StoreParamsCodec.decode(obj) ;
- }
- catch (JsonParseException ex) { return null ; }
- catch (AtlasException ex) { return null ; }
- }
-
- public static JsonObject encodeToJson(StoreParams params) {
- JsonBuilder builder = new JsonBuilder() ;
- builder.startObject("StoreParams") ; // "StoreParams" is an internal alignment marker - not in the JSON.
-
- encode(builder, key(fFileMode), params.getFileMode().name()) ;
- encode(builder, key(fBlockSize), params.getBlockSize()) ;
- encode(builder, key(fBlockReadCacheSize), params.getBlockReadCacheSize()) ;
- encode(builder, key(fBlockWriteCacheSize), params.getBlockWriteCacheSize()) ;
- encode(builder, key(fNode2NodeIdCacheSize), params.getNode2NodeIdCacheSize()) ;
- encode(builder, key(fNodeId2NodeCacheSize), params.getNodeId2NodeCacheSize()) ;
- encode(builder, key(fNodeMissCacheSize), params.getNodeMissCacheSize()) ;
- encode(builder, key(fNodeTableBaseName), params.getNodeTableBaseName()) ;
- encode(builder, key(fPrimaryIndexTriples), params.getPrimaryIndexTriples()) ;
- encode(builder, key(fTripleIndexes), params.getTripleIndexes()) ;
- encode(builder, key(fPrimaryIndexQuads), params.getPrimaryIndexQuads()) ;
- encode(builder, key(fQuadIndexes), params.getQuadIndexes()) ;
- encode(builder, key(fPrefixTableBaseName), params.getPrefixTableBaseName()) ;
- encode(builder, key(fPrimaryIndexPrefix), params.getPrimaryIndexPrefix()) ;
- encode(builder, key(fPrefixIndexes), params.getPrefixIndexes()) ;
-
- builder.finishObject("StoreParams") ;
- return (JsonObject)builder.build() ;
- }
-
- private static final String jsonKeyPrefix= "tdb." ;
-
- private static String key(String string) {
- if ( string.startsWith(jsonKeyPrefix))
- throw new TDBException("Key name already starts with '"+jsonKeyPrefix+"'") ;
- return jsonKeyPrefix+string ;
- }
-
- private static String unkey(String string) {
- if ( ! string.startsWith(jsonKeyPrefix) )
- throw new TDBException("JSON key name does not start with '"+jsonKeyPrefix+"'") ;
- return string.substring(jsonKeyPrefix.length()) ;
- }
-
- public static StoreParams decode(JsonObject json) {
- StoreParamsBuilder builder = StoreParams.builder() ;
-
- for ( String key : json.keys() ) {
- String short_key = unkey(key) ;
- switch(short_key) {
- case fFileMode : builder.fileMode(FileMode.valueOf(getString(json, key))) ; break ;
- case fBlockSize: builder.blockSize(getInt(json, key)) ; break ;
- case fBlockReadCacheSize: builder.blockReadCacheSize(getInt(json, key)) ; break ;
- case fBlockWriteCacheSize: builder.blockWriteCacheSize(getInt(json, key)) ; break ;
- case fNode2NodeIdCacheSize: builder.node2NodeIdCacheSize(getInt(json, key)) ; break ;
- case fNodeId2NodeCacheSize: builder.nodeId2NodeCacheSize(getInt(json, key)) ; break ;
- case fNodeMissCacheSize: builder.nodeMissCacheSize(getInt(json, key)) ; break ;
-
- case fNodeTableBaseName: builder.nodeTableBaseName(getString(json, key)) ; break ;
- case fPrimaryIndexTriples: builder.primaryIndexTriples(getString(json, key)) ; break ;
- case fTripleIndexes: builder.tripleIndexes(getStringArray(json, key)) ; break ;
- case fPrimaryIndexQuads: builder.primaryIndexQuads(getString(json, key)) ; break ;
- case fQuadIndexes: builder.quadIndexes(getStringArray(json, key)) ; break ;
-
- case fPrefixTableBaseName: builder.prefixTableBaseName(getString(json, key)) ; break ;
- case fPrimaryIndexPrefix: builder.primaryIndexPrefix(getString(json, key)) ; break ;
- case fPrefixIndexes: builder.prefixIndexes(getStringArray(json, key)) ; break ;
-
- default:
- throw new TDBException("StoreParams key no recognized: "+key) ;
- }
- }
- return builder.build() ;
- }
-
- // "Get or error" operations.
-
- private static String getString(JsonObject json, String key) {
- if ( ! json.hasKey(key) )
- throw new TDBException("StoreParamsCodec.getString: no such key: "+key) ;
- String x = json.get(key).getAsString().value() ;
- return x ;
- }
-
- private static Integer getInt(JsonObject json, String key) {
- if ( ! json.hasKey(key) )
- throw new TDBException("StoreParamsCodec.getInt: no such key: "+key) ;
- Integer x = json.get(key).getAsNumber().value().intValue() ;
- return x ;
- }
-
- private static String[] getStringArray(JsonObject json, String key) {
- if ( ! json.hasKey(key) )
- throw new TDBException("StoreParamsCodec.getStringArray: no such key: "+key) ;
- JsonArray a = json.get(key).getAsArray() ;
- String[] x = new String[a.size()] ;
- for ( int i = 0 ; i < a.size() ; i++ ) {
- x[i] = a.get(i).getAsString().value() ;
- }
- return x ;
- }
-
- // Encode helper.
- private static void encode(JsonBuilder builder, String name, Object value) {
- if ( value instanceof Number ) {
- long x = ((Number)value).longValue() ;
- builder.key(name).value(x) ;
- return ;
- }
- if ( value instanceof String ) {
- builder.key(name).value(value.toString()) ;
- return ;
- }
- if ( value instanceof String[] ) {
- String[] x = (String[])value ;
- builder.key(name) ;
- builder.startArray() ;
- for ( String s : x ) {
- builder.value(s) ;
- }
- builder.finishArray() ;
- return ;
- }
- throw new TDBException("Class of value not recognized: "+Lib.classShortName(value.getClass())) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsConst.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsConst.java b/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsConst.java
deleted file mode 100644
index f3289b9..0000000
--- a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsConst.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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 org.seaborne.tdb2.setup;
-
-import org.seaborne.dboe.base.block.FileMode ;
-import org.seaborne.dboe.sys.Names ;
-import org.seaborne.tdb2.sys.SystemTDB ;
-
-public class StoreParamsConst {
- // SystemParams are built with a SystemParamsBuilder
- // 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 fNodeTableBaseName = "nodetable" ;
- public static final String nodeTableBaseName = Names.nodeTableBaseName ;
-
- 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 fPrefixTableBaseName = "prefixtable" ;
- public static final String prefixTableBaseName = Names.prefixTableBaseName ;
-
- 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 ;
-
- // Must be after the constants above to get initialization order right
- // because StoreParamsBuilder uses these constants.
-
- /** The system default parameters for on-disk databases. */
- static StoreParams dftStoreParams = StoreParams.builder().build() ;
-
- /** The system default parameters for in-memory databases. */
- static StoreParams dftMemStoreParams = StoreParams.builder()
- .fileMode(FileMode.direct)
- // Small block caches, mainly so it behaves like a direct on-disk database.
- .blockReadCacheSize(10)
- .blockWriteCacheSize(10)
- .node2NodeIdCacheSize(10000)
- .nodeId2NodeCacheSize(10000)
- .nodeMissCacheSize(100)
- .build() ;
-
- /** The "small store" parameters. */
- static StoreParams smallStoreParams = StoreParams.builder()
- .fileMode(FileMode.direct)
- .blockReadCacheSize(100)
- .blockWriteCacheSize(100)
- .node2NodeIdCacheSize(10000)
- .nodeId2NodeCacheSize(10000)
- .nodeMissCacheSize(100)
- .build() ;
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsDynamic.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsDynamic.java b/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsDynamic.java
deleted file mode 100644
index 39ebb67..0000000
--- a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsDynamic.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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 org.seaborne.tdb2.setup;
-
-import org.seaborne.dboe.base.block.FileMode ;
-
-/** Store parameters that can be adjusted after a store has been created,
- * and given different values when the JVM attachs to a store area.
- * (They are still fixed for any given database once created in a JVM.)
- */
-
-public interface StoreParamsDynamic {
-
- /** Store-wide file access mode */
- public FileMode getFileMode() ;
- public boolean isSetFileMode() ;
-
- /** Block read cache (note: mapped files do not have a block cache) */
- public Integer getBlockReadCacheSize() ;
- public boolean isSetBlockReadCacheSize() ;
-
- /** Block write cache (note: mapped files do not have a block cache) */
- public Integer getBlockWriteCacheSize() ;
- public boolean isSetBlockWriteCacheSize() ;
-
- /** Node cache for Node->NodeId. */
- public Integer getNode2NodeIdCacheSize() ;
- public boolean isSetNode2NodeIdCacheSize() ;
-
- /** Node cache for NodeId->Node. Important for SPARQL results. */
- public Integer getNodeId2NodeCacheSize() ;
- public boolean isSetNodeId2NodeCacheSize() ;
-
- /** Node cache for recording known misses */
- public Integer getNodeMissCacheSize() ;
- public boolean isSetNodeMissCacheSize() ;
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsFactory.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsFactory.java b/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsFactory.java
deleted file mode 100644
index f41951f..0000000
--- a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/StoreParamsFactory.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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 org.seaborne.tdb2.setup;
-
-import org.seaborne.dboe.base.file.Location ;
-import org.seaborne.dboe.sys.Names;
-import org.seaborne.tdb2.TDB2Factory ;
-
-public class StoreParamsFactory {
- /** Choose the StoreParams. This is the policy applied when creating or reattaching to a database.
- * (extracted and put here to keep the size of DatasetBuildStd
- * <p>
- * If the location has parameters in a <tt>tdb.cfg</tt> file, use them, as modified by any
- * application-supplied internal parameters.
- * <p>
- * Otherwise, if this is a new database, use the application provided
- * parameters or if there are no application provided
- * parameters, use the system default parameters.
- * Write the parameters used to the location in <tt>tdb.cfg</tt>
- * <p>If this is an existing database and there are no location recorded parameters,
- * use system default parameters, modified by application parameters.
- * <p>
- * Notes:
- * <ul>
- * <li><i>Modification</i> involves setting any of the parameters than can vary from run to run.
- * These are the cache sizes and the file mode.
- * <li><i>Block size</i>: it is critical that this set correctly. Silent corruption
- * of a database may occur if this is changed. At the moment, it is not possible to provide
- * a complete check of block size.
- * <ul>
- * <p>
- * Do not edit store parameters recorded at a location after the database has been created.
- * Only the dynamic parameters cna be safely changed. That is better done though the application
- * providing some parameters in the {@link TDB2Factory} call.
- * <p>
- * This includes changing filenames, indexing choices and block size.
- * Otherwise, the database may be permanetly and irrecovably corrupted.
- * You have been warned.
- *
- * @param location The place where the database is or will be.
- * @param isNew Whether the database is being created or whether there is an existing database.
- * @param pApp Application-provide store parameters.
- * @param pLoc Store parameters foud at the location.
- * @param pDft System default store parameters.
- * @return StoreParams
- *
- * @see StoreParams
- * @see StoreParamsDynamic
- */
- public static StoreParams decideStoreParams(Location location, boolean isNew, StoreParams pApp, StoreParams pLoc, StoreParams pDft) {
- StoreParams p = null ;
- if ( pLoc != null ) {
- // pLoc so use it, modify by pApp.
- // Covers new and reconnect cases.
- p = pLoc ;
- if ( pApp != null )
- p = StoreParamsBuilder.modify(pLoc, pApp) ;
- return p ;
- }
- // No pLoc.
- // Use pApp if available. Write to location if new.
- if ( pApp != null ) {
- if ( isNew ) {
- if ( ! location.isMem() ) {
- String filename = location.getPath(Names.TDB_CONFIG_FILE) ;
- StoreParamsCodec.write(filename, pApp) ;
- }
- return pApp ;
- }
- // Not new : pLoc is implicitly pDft.
- return StoreParamsBuilder.modify(pDft, pApp) ;
- }
- // no pLoc, no pApp
- return pDft ;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/TDBBuilder.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/TDBBuilder.java b/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/TDBBuilder.java
deleted file mode 100644
index 0014c16..0000000
--- a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/TDBBuilder.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * 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 org.seaborne.tdb2.setup;
-
-import java.io.File ;
-import java.io.FileFilter ;
-import java.util.UUID ;
-
-import org.apache.jena.atlas.lib.tuple.TupleMap ;
-import org.apache.jena.sparql.engine.main.QC ;
-import org.apache.jena.sparql.engine.optimizer.reorder.ReorderLib ;
-import org.seaborne.dboe.DBOpEnvException ;
-import org.seaborne.dboe.base.file.* ;
-import org.seaborne.dboe.base.record.RecordFactory ;
-import org.seaborne.dboe.index.Index ;
-import org.seaborne.dboe.index.RangeIndex ;
-import org.seaborne.dboe.sys.Names ;
-import org.seaborne.dboe.trans.bplustree.BPlusTree ;
-import org.seaborne.dboe.trans.bplustree.BPlusTreeFactory ;
-import org.seaborne.dboe.trans.data.TransBinaryDataFile ;
-import org.seaborne.dboe.transaction.txn.ComponentId ;
-import org.seaborne.dboe.transaction.txn.TransactionCoordinator ;
-import org.seaborne.dboe.transaction.txn.TransactionalBase ;
-import org.seaborne.dboe.transaction.txn.TransactionalSystem ;
-import org.seaborne.dboe.transaction.txn.journal.Journal ;
-import org.seaborne.tdb2.TDBException ;
-import org.seaborne.tdb2.solver.OpExecutorTDB1 ;
-import org.seaborne.tdb2.store.* ;
-import org.seaborne.tdb2.store.nodetable.NodeTable ;
-import org.seaborne.tdb2.store.nodetable.NodeTableCache ;
-import org.seaborne.tdb2.store.nodetable.NodeTableInline ;
-import org.seaborne.tdb2.store.nodetable.NodeTableTRDF ;
-import org.seaborne.tdb2.store.nodetupletable.NodeTupleTable ;
-import org.seaborne.tdb2.store.nodetupletable.NodeTupleTableConcrete ;
-import org.seaborne.tdb2.store.tupletable.TupleIndex ;
-import org.seaborne.tdb2.store.tupletable.TupleIndexRecord ;
-import org.seaborne.tdb2.sys.SystemTDB ;
-import org.slf4j.Logger ;
-import org.slf4j.LoggerFactory ;
-
-// Takes from TDB2Builder
-// Converted to statics.
-
-/** Build TDB2 databases.
- * <p>
- * <b>Do not call these operations directly - use StoreConnection.</b>
- */
-public class TDBBuilder {
- private Logger log = LoggerFactory.getLogger(TDBBuilder.class) ;
-
- public static DatasetGraphTxn build(Location location) {
- return build(location, StoreParams.getDftStoreParams()) ;
- }
-
- public static DatasetGraphTxn build(Location location, StoreParams appParams) {
- StoreParams locParams = StoreParamsCodec.read(location) ;
- StoreParams dftParams = StoreParams.getDftStoreParams() ;
- // This can write the chosen parameters if necessary (new database, appParams != null, locParams == null)
- boolean newArea = isNewDatabaseArea(location) ;
- if ( newArea ) {
- }
- StoreParams params = StoreParamsFactory.decideStoreParams(location, newArea, appParams, locParams, dftParams) ;
- return create(location, params).build$() ;
- }
-
- private DatasetGraphTxn build$() {
- NodeTable nodeTable = buildNodeTable(params.getNodeTableBaseName()) ;
-
- TripleTable tripleTable = buildTripleTable(nodeTable) ;
- QuadTable quadTable = buildQuadTable(nodeTable) ;
-
- NodeTable nodeTablePrefixes = buildNodeTable(params.getPrefixTableBaseName()) ;
- DatasetPrefixesTDB prefixes = buildPrefixTable(nodeTablePrefixes) ;
-
- TransactionalSystem trans = new TransactionalBase(txnCoord) ;
- DatasetGraphTxn dsg = new DatasetGraphTDB(trans,
- tripleTable, quadTable, prefixes,
- ReorderLib.fixed(), location, params) ;
- QC.setFactory(dsg.getContext(), OpExecutorTDB1.OpExecFactoryTDB) ;
- txnCoord.start() ;
- return dsg ;
- }
-
- public static TransactionCoordinator buildTransactionCoordinator(Location location) {
- Journal journal = Journal.create(location) ;
- TransactionCoordinator txnCoord = new TransactionCoordinator(journal) ;
- return txnCoord ;
- }
-
- public static String choosePrimaryForIndex(StoreParams params, String index) {
- String primary3 = params.getPrimaryIndexTriples() ;
- String primary4 = params.getPrimaryIndexQuads() ;
-
- if ( index.length() == primary3.length() )
- return primary3 ;
- if ( index.length() == primary4.length() )
- return primary4 ;
- throw new DBOpEnvException("Can't find primary for '"+index+"'") ;
- }
-
- // ---- Object starts
- final Location location ;
- final StoreParams params ;
- final ComponentIdMgr componentIdMgr ;
- final TransactionCoordinator txnCoord ;
-
- private TDBBuilder(TransactionCoordinator txnCoord, Location location, StoreParams params, ComponentIdMgr componentIdMgr) {
- this.txnCoord = txnCoord ;
- this.location = location ;
- this.params = params ;
- this.componentIdMgr = componentIdMgr ;
- }
-
- public Location getLocation() { return location ; }
- public StoreParams getParams() { return params ; }
- public TransactionCoordinator getTxnCoord() { return txnCoord ; }
-
- public static TDBBuilder create(Location location) {
- return create(location, StoreParams.getDftStoreParams()) ;
- }
-
- public static TDBBuilder create(Location location, StoreParams params) {
- TransactionCoordinator txnCoord = buildTransactionCoordinator(location) ;
- return new TDBBuilder(txnCoord, location, params, new ComponentIdMgr(UUID.randomUUID())) ;
- }
-
- public static TDBBuilder create(TransactionCoordinator txnCoord, Location location, StoreParams params) {
- return new TDBBuilder(txnCoord, location, params, new ComponentIdMgr(UUID.randomUUID())) ;
- }
-
- /** Look at a directory and see if it is a new area */
- private static boolean isNewDatabaseArea(Location location) {
- if ( location.isMem() )
- return true ;
- File d = new File(location.getDirectoryPath()) ;
- if ( !d.exists() )
- return true ;
- FileFilter ff = fileFilterNewDB ;
- File[] entries = d.listFiles(ff) ;
- return entries.length == 0 ;
- }
-
- /** FileFilter
- * Skips "..", ".", "tdb.lock" and "tdb.cfg"
- *
- */
- private static FileFilter fileFilterNewDB = (pathname)->{
- String fn = pathname.getName() ;
- if ( fn.equals(".") || fn.equals("..") )
- return false ;
- if ( pathname.isDirectory() )
- return true ;
- if ( fn.equals(Names.TDB_LOCK_FILE) )
- return false ;
- if ( fn.equals(Names.TDB_CONFIG_FILE) )
- return false ;
-
- return true ;
- } ;
-
- public TripleTable buildTripleTable(NodeTable nodeTable) {
- String primary = params.getPrimaryIndexTriples() ;
- String[] indexes = params.getTripleIndexes() ;
-
- // Validation checks - common index forms.
- if ( indexes.length != 3 && indexes.length != 2 )
- error(log, "Wrong number of triple table indexes: "+String.join(",", indexes)) ;
- log.debug("Triple table: "+primary+" :: "+String.join(",", indexes)) ;
-
- TupleIndex tripleIndexes[] = makeTupleIndexes(primary, indexes) ;
-
- if ( tripleIndexes.length != indexes.length )
- error(log, "Wrong number of triple table tuples indexes: "+tripleIndexes.length) ;
- TripleTable tripleTable = new TripleTable(tripleIndexes, nodeTable) ;
- return tripleTable ;
- }
-
- public QuadTable buildQuadTable(NodeTable nodeTable) {
- String primary = params.getPrimaryIndexQuads() ;
- String[] indexes = params.getQuadIndexes() ;
-
- // Validation checks - common index forms.
- if ( indexes.length != 6 && indexes.length != 4 )
- error(log, "Wrong number of quad table indexes: "+String.join(",", indexes)) ;
- log.debug("Quad table: "+primary+" :: "+String.join(",", indexes)) ;
-
- TupleIndex tripleIndexes[] = makeTupleIndexes(primary, indexes) ;
-
- if ( tripleIndexes.length != indexes.length )
- error(log, "Wrong number of triple table tuples indexes: "+tripleIndexes.length) ;
- QuadTable tripleTable = new QuadTable(tripleIndexes, nodeTable) ;
- return tripleTable ;
- }
-
- public DatasetPrefixesTDB buildPrefixTable(NodeTable prefixNodes) {
- String primary = params.getPrimaryIndexPrefix() ;
- String[] indexes = params.getPrefixIndexes() ;
-
- TupleIndex prefixIndexes[] = makeTupleIndexes(primary, indexes) ;
- if ( prefixIndexes.length != 1 )
- error(log, "Wrong number of triple table tuples indexes: "+prefixIndexes.length) ;
-
- // No cache - the prefix mapping is a cache
- //NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, pnId2Node, -1, -1, -1) ;
- NodeTupleTable prefixTable = new NodeTupleTableConcrete(primary.length(),
- prefixIndexes,
- prefixNodes) ;
- DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixTable) ;
- log.debug("Prefixes: "+primary+" :: "+String.join(",", indexes)) ;
- return prefixes ;
- }
-
- // ---- Build structures
-
- public TupleIndex[] makeTupleIndexes(String primary, String[] indexNames) {
- int indexRecordLen = primary.length()*SystemTDB.SizeOfNodeId ;
- TupleIndex indexes[] = new TupleIndex[indexNames.length] ;
- for (int i = 0 ; i < indexes.length ; i++) {
- String indexName = indexNames[i] ;
- String indexLabel = indexNames[i] ;
- indexes[i] = buildTupleIndex(primary, indexName, indexLabel) ;
- }
- return indexes ;
- }
-
- public TupleIndex buildTupleIndex(String primary, String index, String name) {
- TupleMap cmap = TupleMap.create(primary, index) ;
- RecordFactory rf = new RecordFactory(SystemTDB.SizeOfNodeId * cmap.length(), 0) ;
- RangeIndex rIdx = buildRangeIndex(rf, index) ;
- TupleIndex tIdx = new TupleIndexRecord(primary.length(), cmap, index, rf, rIdx) ;
- return tIdx ;
- }
-
- public RangeIndex buildRangeIndex(RecordFactory recordFactory, String name) {
- ComponentId cid = componentIdMgr.getComponentId(name) ;
- FileSet fs = new FileSet(location, name) ;
- BPlusTree bpt = BPlusTreeFactory.createBPTree(cid, fs, recordFactory) ;
- txnCoord.add(bpt) ;
- return bpt ;
- }
-
- public NodeTable buildNodeTable(String name) {
- NodeTable nodeTable = buildBaseNodeTable(name) ;
- nodeTable = NodeTableCache.create(nodeTable, params) ;
- nodeTable = NodeTableInline.create(nodeTable) ;
- return nodeTable ;
- }
-
- public NodeTable buildBaseNodeTable(String name) {
- RecordFactory recordFactory = new RecordFactory(SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId) ;
- Index index = buildRangeIndex(recordFactory, name) ;
-
- String dataname = name+"-data" ;
- TransBinaryDataFile transBinFile = buildBinaryDataFile(dataname) ;
- txnCoord.add(transBinFile) ;
- return new NodeTableTRDF(index, transBinFile) ;
- }
-
- public TransBinaryDataFile buildBinaryDataFile(String name) {
- ComponentId cid = componentIdMgr.getComponentId(name) ;
- FileSet fs = new FileSet(location, name) ;
- BinaryDataFile binFile = FileFactory.createBinaryDataFile(fs, Names.extObjNodeData) ;
- BufferChannel pState = FileFactory.createBufferChannel(fs, Names.extBdfState) ;
- // ComponentId mgt.
- TransBinaryDataFile transBinFile = new TransBinaryDataFile(binFile, cid, pState) ;
- return transBinFile ;
- }
-
- private void error(Logger log, String msg)
- {
- if ( log != null )
- log.error(msg) ;
- throw new TDBException(msg) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/TDBDatasetDetails.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/TDBDatasetDetails.java b/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/TDBDatasetDetails.java
deleted file mode 100644
index 60b028d..0000000
--- a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/setup/TDBDatasetDetails.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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 org.seaborne.tdb2.setup;
-
-import org.apache.jena.atlas.lib.ArrayUtils ;
-import org.apache.jena.atlas.logging.Log ;
-import org.seaborne.tdb2.store.DatasetGraphTDB ;
-import org.seaborne.tdb2.store.nodetable.NodeTable ;
-import org.seaborne.tdb2.store.nodetable.NodeTableCache ;
-import org.seaborne.tdb2.store.nodetable.NodeTableInline ;
-import org.seaborne.tdb2.store.tupletable.TupleIndex ;
-
-public class TDBDatasetDetails {
- public final TupleIndex[] tripleIndexes ;
- public final TupleIndex[] quadIndexes ;
- public final NodeTable ntTop ;
- public NodeTableInline ntInline ;
- public NodeTableCache ntCache ;
- public NodeTable ntBase ;
-
-
- public TDBDatasetDetails(DatasetGraphTDB dsg) {
- ntTop = dsg.getTripleTable().getNodeTupleTable().getNodeTable() ;
- tripleIndexes = ArrayUtils.copy(dsg.getTripleTable().getNodeTupleTable().getTupleTable().getIndexes()) ;
- quadIndexes = ArrayUtils.copy(dsg.getQuadTable().getNodeTupleTable().getTupleTable().getIndexes()) ;
-
- fillInNodeTableDetails() ;
- fillInIndexDetails() ;
- }
-
- private void fillInNodeTableDetails() {
- // Nodetable.
- NodeTable ntx = ntTop ;
- while(ntx.wrapped() != null ) {
- if ( ntx instanceof NodeTableInline ) {
- if ( ntInline != null )
- Log.warn(this, "Multiple NodeTableInline") ;
- ntInline = (NodeTableInline)ntx ;
- }
- else if ( ntx instanceof NodeTableCache ) {
- if ( ntCache != null )
- Log.warn(this, "Multiple NodeTableCache") ;
- ntCache = (NodeTableCache)ntx ;
- }
- ntx = ntx.wrapped() ;
- }
-
- ntBase = ntx ;
-
- if ( ntInline == null )
- Log.warn(this, "No NodeTableInline") ;
- if ( ntCache == null )
- Log.warn(this, "No NodeTableCache") ;
- if ( ntBase == null )
- Log.warn(this, "No base NodeTable") ;
- }
-
- private void fillInIndexDetails() {
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/solver/Abortable.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/solver/Abortable.java b/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/solver/Abortable.java
deleted file mode 100644
index d5d3167..0000000
--- a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/solver/Abortable.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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 org.seaborne.tdb2.solver;
-
-interface Abortable { public void abort() ; }
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/solver/BindingNodeId.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/solver/BindingNodeId.java b/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/solver/BindingNodeId.java
deleted file mode 100644
index 76db1ce..0000000
--- a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/solver/BindingNodeId.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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 org.seaborne.tdb2.solver;
-
-import java.util.HashMap;
-import java.util.Iterator ;
-import java.util.Map;
-
-import org.apache.jena.atlas.lib.Map2 ;
-
-
-
-import org.apache.jena.sparql.core.Var ;
-import org.apache.jena.sparql.engine.binding.Binding ;
-import org.seaborne.tdb2.store.NodeId ;
-
-/** Class for a Binding-like structure except it works on NodeIds, not on Nodes */
-public class BindingNodeId extends Map2<Var, NodeId>
-{
- // This is the parent binding - which may be several steps up the chain.
- // This just carried around for later use when we go BindingNodeId back to Binding.
- private final Binding parentBinding ;
-
- // Possible optimization: there are at most 3 possible values so HashMap is overkill.
- // Use a chain of small objects.
-
- private BindingNodeId(Map<Var, NodeId> map1, Map2<Var, NodeId> map2, Binding parentBinding)
- {
- super(map1, map2) ;
- this.parentBinding = parentBinding ;
- }
-
- // Make from an existing BindingNodeId
- public BindingNodeId(BindingNodeId other)
- {
- this(new HashMap<Var, NodeId>(), other, other.getParentBinding()) ;
- }
-
- // Make from an existing Binding
- public BindingNodeId(Binding binding)
- {
- this(new HashMap<Var, NodeId>(), null, binding) ;
- }
-
- public BindingNodeId()
- {
- this(new HashMap<Var, NodeId>(), null, null) ;
- }
-
- public Binding getParentBinding() { return parentBinding ; }
-
- //@Override public NodeId get(Var v) { return super.get(v) ; }
-
- @Override public void put(Var v, NodeId n)
- {
- if ( v == null || n == null )
- throw new IllegalArgumentException("("+v+","+n+")") ;
- super.put(v, n) ;
- }
-
- public void putAll(BindingNodeId other)
- {
- Iterator<Var> vIter = other.iterator() ;
-
- for ( ; vIter.hasNext() ; )
- {
- Var v = vIter.next() ;
- if ( v == null )
- throw new IllegalArgumentException("Null key") ;
- NodeId n = other.get(v) ;
- if ( n == null )
- throw new IllegalArgumentException("("+v+","+n+")") ;
- super.put(v, n) ;
- }
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder() ;
-
- boolean first = true ;
- for ( Var v : this )
- {
- if ( ! first )
- sb.append(" ") ;
- first = false ;
- NodeId x = get(v) ;
- sb.append(v) ;
- sb.append(" = ") ;
- sb.append(x) ;
- }
-
- return sb.toString() ;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/solver/BindingTDB.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/solver/BindingTDB.java b/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/solver/BindingTDB.java
deleted file mode 100644
index 22d85d0..0000000
--- a/jena-db/jena-tdb2/src/main/java/org/seaborne/tdb2/solver/BindingTDB.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * 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 org.seaborne.tdb2.solver;
-
-import java.util.* ;
-
-import org.apache.jena.atlas.logging.Log ;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.riot.out.NodeFmtLib ;
-import org.apache.jena.sparql.core.Var ;
-import org.apache.jena.sparql.engine.binding.Binding ;
-import org.apache.jena.sparql.engine.binding.BindingBase ;
-import org.seaborne.tdb2.store.NodeId ;
-import org.seaborne.tdb2.store.nodetable.NodeTable ;
-
-/** Bind that delays turning a NodeId into a Node until explicitly needed by get() */
-
-public class BindingTDB extends BindingBase
-{
- private final NodeTable nodeTable ;
- private final BindingNodeId idBinding ;
-
- private static final boolean caching = false ;
- // Whether the cache is worthwhile is unclear - the NodeTable keeps a cache.
- private final Map<Var,Node> cache = ( caching ? new HashMap<>() : null ) ;
-
- public BindingTDB(BindingNodeId idBinding, NodeTable nodeTable)
- {
- // BindingNodeId contains the bindings actually used copied down when created.
- super(idBinding.getParentBinding()) ;
- this.idBinding = idBinding ;
- this.nodeTable = nodeTable ;
- }
-
- @Override
- protected int size1() { return idBinding.size(); }
-
- private List<Var> vars = null ;
-
- /** Iterate over all the names of variables. */
- @Override
- protected Iterator<Var> vars1()
- {
- if ( vars == null )
- vars = calcVars() ;
- return vars.iterator() ;
- }
-
- private List<Var> calcVars()
- {
- List<Var> vars = new ArrayList<>(4) ;
- // Only if not in parent.
- // A (var/value) binding may have been copied down to record it's NodeId.
-
- Binding b = idBinding.getParentBinding() ;
-
- Iterator<Var> iter = idBinding.iterator() ;
- for ( Var v : idBinding )
- {
- if ( b == null || ! b.contains(v) )
- vars.add(v) ;
- }
- return vars ;
- }
-
- @Override
- protected boolean isEmpty1()
- {
- return size1() == 0 ;
- }
-
- @Override
- public boolean contains1(Var var)
- {
- return idBinding.containsKey(var) ;
- }
-
- public BindingNodeId getBindingId() { return idBinding ; }
-
- public NodeId getNodeId(Var var)
- {
- NodeId id = idBinding.get(var) ;
- if ( id != null )
- return id ;
-
- if ( parent == null )
- return null ;
-
- // Maybe in the parent.
- if ( parent instanceof BindingTDB )
- return ((BindingTDB)parent).getNodeId(var) ;
- return null ;
- }
-
- @Override
- public Node get1(Var var)
- {
- try {
- Node n = cacheGet(var) ;
- if ( n != null )
- return n ;
-
- NodeId id = idBinding.get(var) ;
- if ( id == null )
- return null ;
- n = nodeTable.getNodeForNodeId(id) ;
- // Update cache.
- cachePut(var, n) ;
- return n ;
- } catch (Exception ex)
- {
- Log.error(this, String.format("get1(%s)", var), ex) ;
- return null ;
- }
- }
-
- private void cachePut(Var var, Node n)
- {
- if ( cache != null ) cache.put(var, n) ;
- }
-
- private Node cacheGet(Var var)
- {
- if ( cache == null ) return null ;
- return cache.get(var) ;
- }
-
- @Override
- protected void format(StringBuffer sbuff, Var var)
- {
- NodeId id = idBinding.get(var) ;
- String extra = "" ;
- if ( id != null )
- extra = "/"+id ;
- Node node = get(var) ;
- String tmp = NodeFmtLib.displayStr(node) ;
- sbuff.append("( ?"+var.getVarName()+extra+" = "+tmp+" )") ;
- }
-}