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 2011/06/29 16:54:36 UTC
svn commit: r1141122 - in /incubator/jena/Experimental/TxTDB/trunk:
src-dev/tx/ src/main/java/com/hp/hpl/jena/tdb/index/factories/
src/main/java/com/hp/hpl/jena/tdb/nodetable/
src/main/java/com/hp/hpl/jena/tdb/setup/
src/main/java/com/hp/hpl/jena/tdb/s...
Author: andy
Date: Wed Jun 29 14:54:35 2011
New Revision: 1141122
URL: http://svn.apache.org/viewvc?rev=1141122&view=rev
Log: (empty)
Added:
incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/AbstractTestNodeTableTrans.java (with props)
incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/Builder.java (with props)
incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TestNodeTableTrans.java (with props)
Removed:
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java
Modified:
incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/NodeTableTrans.java
incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/factories/IndexFactoryBPlusTree.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTable.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableInline.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableLogger.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableNative.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableSink.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableWrapper.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdIndexBuild.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/Names.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/tdb/CmdRewriteIndex.java
incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/bplustree/TestBPlusTreeRewriter.java
incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/store/TestGraphTDB.java
Added: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/AbstractTestNodeTableTrans.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/AbstractTestNodeTableTrans.java?rev=1141122&view=auto
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/AbstractTestNodeTableTrans.java (added)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/AbstractTestNodeTableTrans.java Wed Jun 29 14:54:35 2011
@@ -0,0 +1,39 @@
+/**
+ * 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 tx;
+
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.sparql.util.NodeFactory ;
+
+import org.junit.Test ;
+
+public abstract class AbstractTestNodeTableTrans
+{
+ abstract NodeTableTrans getEmpty() ;
+
+ static Node node1 = NodeFactory.parseNode("<x>") ;
+ static Node node2 = NodeFactory.parseNode("<y>") ;
+
+ @Test public void test()
+ {
+
+ }
+
+}
+
Propchange: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/AbstractTestNodeTableTrans.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/Builder.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/Builder.java?rev=1141122&view=auto
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/Builder.java (added)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/Builder.java Wed Jun 29 14:54:35 2011
@@ -0,0 +1,128 @@
+/**
+ * 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 tx;
+
+import com.hp.hpl.jena.tdb.base.block.BlockMgr ;
+import com.hp.hpl.jena.tdb.base.block.BlockMgrFactory ;
+import com.hp.hpl.jena.tdb.base.file.FileFactory ;
+import com.hp.hpl.jena.tdb.base.file.FileSet ;
+import com.hp.hpl.jena.tdb.base.objectfile.ObjectFile ;
+import com.hp.hpl.jena.tdb.base.record.RecordFactory ;
+import com.hp.hpl.jena.tdb.index.Index ;
+import com.hp.hpl.jena.tdb.index.RangeIndex ;
+import com.hp.hpl.jena.tdb.index.bplustree.BPlusTree ;
+import com.hp.hpl.jena.tdb.index.bplustree.BPlusTreeParams ;
+import com.hp.hpl.jena.tdb.sys.Names ;
+import com.hp.hpl.jena.tdb.sys.SystemTDB ;
+
+public final class Builder
+{
+ // Yet another attempt to have one place to "build things"
+ // See DatasetBuilderStd.
+
+ // Use standard defaults.
+ // Go back and find all other attempts and remove.
+
+ // Become a library of builders - take code from DatasetBuilderStd
+
+ public static Index createIndex(FileSet fileset, RecordFactory recordFactory)
+ {
+ return createRangeIndex(fileset, recordFactory) ;
+ }
+
+ public static RangeIndex createRangeIndex(FileSet fileset, RecordFactory recordFactory)
+ {
+ if ( fileset.isMem() )
+ return createRangeIndex$(fileset, recordFactory) ;
+ else
+ return createRangeIndexMem$(fileset, recordFactory) ;
+ }
+
+ private static RangeIndex createRangeIndex$(FileSet fileset, RecordFactory recordFactory)
+ {
+ return createBPlusTree$(fileset, recordFactory) ;
+ }
+
+ private static RangeIndex createRangeIndexMem$(FileSet fileset, RecordFactory recordFactory)
+ {
+ return createBPlusTreeMem$(fileset, recordFactory) ;
+ }
+
+ public static BPlusTree createBPlusTree(FileSet fileset, RecordFactory recordFactory)
+ {
+ if ( fileset.isMem() )
+ return createBPlusTreeMem$(fileset, recordFactory) ;
+ else
+ return createBPlusTree$(fileset, recordFactory) ;
+
+ }
+
+ private static BPlusTree createBPlusTree$(FileSet fileset, RecordFactory recordFactory)
+ {
+ int order = BPlusTreeParams.calcOrder(params.blockSize , recordFactory) ;
+ BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory) ;
+ BlockMgr blkMgrRecords = createBlockMgr$(fileset, Names.bptExtRecords, recordFactory) ;
+ BlockMgr blkMgrNodes = createBlockMgr$(fileset, Names.bptExtTree, recordFactory) ;
+ BPlusTree bpt =BPlusTree.attach(bptParams, blkMgrNodes, blkMgrRecords) ;
+ return bpt ;
+ }
+
+ private static BPlusTree createBPlusTreeMem$(FileSet fileset, RecordFactory recordFactory)
+ {
+ int order = BPlusTreeParams.calcOrder(params.memBlockSize , recordFactory) ;
+ BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory) ;
+ BlockMgr blkMgrRecords = createBlockMgrMem$(fileset, Names.bptExtRecords, recordFactory) ;
+ BlockMgr blkMgrNodes = createBlockMgrMem$(fileset, Names.bptExtTree, recordFactory) ;
+ BPlusTree bpt = BPlusTree.attach(bptParams, blkMgrNodes, blkMgrRecords) ;
+ return bpt ;
+ }
+
+ private static BlockMgr createBlockMgr$(FileSet fileset, String ext, RecordFactory recordFactory)
+ {
+ return BlockMgrFactory.create(fileset, ext, params.blockSize, params.readCacheSize, params.writeCacheSize) ;
+ }
+
+ private static BlockMgr createBlockMgrMem$(FileSet fileset, String ext, RecordFactory recordFactory)
+ {
+ return BlockMgrFactory.createMem(fileset.getBasename(), params.memBlockSize) ;
+ }
+
+ public static ObjectFile createObjectFile(FileSet fileset)
+ {
+ if ( fileset.isMem() )
+ return FileFactory.createObjectFileMem() ;
+ else
+ return FileFactory.createObjectFileDisk(fileset.filename(Names.extNodeData)) ;
+ }
+
+ private static Params params = new Params() ;
+
+ // The standard setting
+ private static class Params
+ {
+ final int blockSize = SystemTDB.BlockSize ;
+ final int memBlockSize = SystemTDB.BlockSizeTestMem ;
+ final int readCacheSize = SystemTDB.BlockReadCacheSize ;
+ final int writeCacheSize = SystemTDB.BlockWriteCacheSize ;
+ }
+
+}
+
+
+
Propchange: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/Builder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/NodeTableTrans.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/NodeTableTrans.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/NodeTableTrans.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/NodeTableTrans.java Wed Jun 29 14:54:35 2011
@@ -19,77 +19,148 @@
package tx;
import java.util.Iterator ;
-import java.util.Map ;
+import org.openjena.atlas.iterator.Iter ;
import org.openjena.atlas.lib.Pair ;
import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.tdb.TDBException ;
import com.hp.hpl.jena.tdb.base.objectfile.ObjectFile ;
+import com.hp.hpl.jena.tdb.index.Index ;
import com.hp.hpl.jena.tdb.nodetable.NodeTable ;
+import com.hp.hpl.jena.tdb.nodetable.NodeTableCache ;
+import com.hp.hpl.jena.tdb.nodetable.NodeTableNative ;
import com.hp.hpl.jena.tdb.store.NodeId ;
+import com.hp.hpl.jena.tdb.transaction.Transaction ;
+import com.hp.hpl.jena.tdb.transaction.Transactional ;
-public class NodeTableTrans implements NodeTable
+public class NodeTableTrans implements NodeTable, Transactional
{
- private final NodeTable other ;
+ private final NodeTable base ;
private final long offset ;
private final ObjectFile journal ;
- private Map<Node, NodeId> node2NodeId ;
- private Map<NodeId, Node> nodeId2Node ;
-
- public NodeTableTrans(NodeTable sub, long offset, ObjectFile journal)
+ private NodeTable nodeTableJournal ;
+ private static int CacheSize = 10000 ;
+ private boolean passthrough = false ;
+
+ public NodeTableTrans(Transaction txn, NodeTable sub, long offset, Index tmpIndex, ObjectFile journal)
{
- this.other = sub ;
+ this.base = sub ;
this.offset = offset ;
this.journal = journal ;
+ // This is a temporary file, and does not itself need to be transactional.
+ // It's used to scale the transactional node table.
+ // We need direct access to the ObjectFile for reply after crash.
+
+ this.nodeTableJournal = new NodeTableNative(tmpIndex, journal) ;
+ this.nodeTableJournal = NodeTableCache.create(nodeTableJournal, CacheSize, CacheSize) ;
}
+ public void setPassthrough(boolean v) { passthrough = v ; }
+
@Override
public NodeId getAllocateNodeId(Node node)
{
+ if ( passthrough ) return base.getAllocateNodeId(node) ;
NodeId nodeId = getNodeIdForNode(node) ;
if ( ! NodeId.doesNotExist(nodeId) )
return nodeId ;
// add to journal
nodeId = allocate(node) ;
- // Convert
- long x = nodeId.getId() ;
- nodeId = new NodeId(x+offset) ;
- node2NodeId.put(node, nodeId) ;
- nodeId2Node.put(nodeId, node) ;
-
return nodeId ;
}
@Override
public NodeId getNodeIdForNode(Node node)
{
- NodeId nodeId = node2NodeId.get(node) ;
- if ( nodeId != null )
- return nodeId ;
- nodeId = other.getNodeIdForNode(node) ;
+ if ( passthrough ) return base.getNodeIdForNode(node) ;
+ NodeId nodeId = nodeTableJournal.getNodeIdForNode(node) ;
+ if ( ! NodeId.doesNotExist(nodeId) )
+ return mapFromJournal(nodeId) ;
+ nodeId = base.getNodeIdForNode(node) ;
return nodeId ;
}
+ /** Convert from a id to the id in the "journal" file */
+ private NodeId mapToJournal(NodeId id) { return NodeId.create(id.getId()-offset) ; }
+
+ /** Convert from a id in other to an external id */
+ private NodeId mapFromJournal(NodeId id) { return NodeId.create(id.getId()+offset) ; }
+
@Override
public Node getNodeForNodeId(NodeId id)
{
- Node node = nodeId2Node.get(id) ;
- if ( node != null )
- return node ;
- node = other.getNodeForNodeId(id) ;
+ if ( passthrough ) return base.getNodeForNodeId(id) ;
+ long x = id.getId() ;
+ if ( x < offset )
+ return base.getNodeForNodeId(id) ;
+ id = mapToJournal(id) ;
+ Node node = nodeTableJournal.getNodeForNodeId(id) ;
return node ;
}
private NodeId allocate(Node node)
{
- return null ;
+ NodeId nodeId = nodeTableJournal.getAllocateNodeId(node) ;
+ nodeId = mapFromJournal(nodeId) ;
+ return nodeId ;
+ }
+
+ @Override
+ public NodeId allocOffset()
+ {
+ NodeId x = nodeTableJournal.allocOffset() ;
+ return mapFromJournal(x) ;
+ }
+
+ @Override
+ public void begin(Transaction txn)
+ {
+ passthrough = false ;
+// inTransaction = true ;
+// journal.position(0) ;
+// this.otherAllocOffset = journal.length() ;
+ }
+
+ /** Copy from the journal file to the real file */
+ public /*temporary*/ void append()
+ {
+ // Asummes all() is in order from low to high.
+ Iterator<Pair<NodeId, Node>> iter = nodeTableJournal.all() ;
+ for ( ; iter.hasNext() ; )
+ {
+ Pair<NodeId, Node> x = iter.next() ;
+ NodeId nodeId = x.getLeft() ;
+ Node node = x.getRight() ;
+ NodeId nodeId2 = base.getAllocateNodeId(node) ;
+ if ( ! nodeId2.equals(mapFromJournal(nodeId)) )
+ throw new TDBException(String.format("Different ids allocated: expected %s, got %s\n", nodeId, nodeId2)) ;
+ }
+ }
+
+ @Override
+ public void commit(Transaction txn)
+ {
+// if ( ! inTransaction )
+// throw new TDBTransactionException("Not in a transaction for a commit to happen") ;
+// append() ;
+// base.sync() ;
+// other.reposition(0) ;
+// passthrough = true ;
+ }
+
+ @Override
+ public void abort(Transaction txn)
+ {
+// other.reposition(0) ;
}
@Override
public Iterator<Pair<NodeId, Node>> all()
{
- return null ;
+ // Better would be to convert the spill file format.
+ return Iter.concat(base.all(), nodeTableJournal.all()) ;
}
@Override
Added: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TestNodeTableTrans.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TestNodeTableTrans.java?rev=1141122&view=auto
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TestNodeTableTrans.java (added)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TestNodeTableTrans.java Wed Jun 29 14:54:35 2011
@@ -0,0 +1,25 @@
+/**
+ * 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 tx;
+
+public class TestNodeTableTrans
+{
+
+}
+
Propchange: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TestNodeTableTrans.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java Wed Jun 29 14:54:35 2011
@@ -10,6 +10,7 @@ import org.openjena.atlas.lib.Bytes ;
import org.openjena.atlas.lib.FileOps ;
import org.openjena.atlas.logging.Log ;
+import com.hp.hpl.jena.graph.Node ;
import com.hp.hpl.jena.graph.Triple ;
import com.hp.hpl.jena.query.DatasetFactory ;
import com.hp.hpl.jena.query.Query ;
@@ -17,22 +18,31 @@ import com.hp.hpl.jena.query.QueryExecut
import com.hp.hpl.jena.query.QueryExecutionFactory ;
import com.hp.hpl.jena.query.QueryFactory ;
import com.hp.hpl.jena.query.Syntax ;
+import com.hp.hpl.jena.query.larq.IndexBuilder ;
import com.hp.hpl.jena.rdf.model.Model ;
import com.hp.hpl.jena.rdf.model.ModelFactory ;
import com.hp.hpl.jena.sparql.core.DatasetGraph ;
import com.hp.hpl.jena.sparql.core.DatasetPrefixStorage ;
import com.hp.hpl.jena.sparql.core.Quad ;
import com.hp.hpl.jena.sparql.sse.SSE ;
+import com.hp.hpl.jena.sparql.util.NodeFactory ;
import com.hp.hpl.jena.sparql.util.QueryExecUtils ;
import com.hp.hpl.jena.tdb.TDBFactory ;
import com.hp.hpl.jena.tdb.base.block.FileMode ;
+import com.hp.hpl.jena.tdb.base.file.FileFactory ;
+import com.hp.hpl.jena.tdb.base.objectfile.ObjectFile ;
import com.hp.hpl.jena.tdb.base.record.Record ;
import com.hp.hpl.jena.tdb.base.record.RecordFactory ;
+import com.hp.hpl.jena.tdb.index.Index ;
import com.hp.hpl.jena.tdb.index.TupleIndex ;
+import com.hp.hpl.jena.tdb.index.bplustree.BPlusTree ;
import com.hp.hpl.jena.tdb.nodetable.NodeTable ;
+import com.hp.hpl.jena.tdb.nodetable.NodeTableInline ;
import com.hp.hpl.jena.tdb.nodetable.NodeTupleTable ;
import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
import com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB ;
+import com.hp.hpl.jena.tdb.store.NodeId ;
+import com.hp.hpl.jena.tdb.sys.Names ;
import com.hp.hpl.jena.tdb.sys.SystemTDB ;
import com.hp.hpl.jena.tdb.transaction.DatasetGraphTxnTDB ;
import com.hp.hpl.jena.tdb.transaction.TransactionManager ;
@@ -63,6 +73,10 @@ public class TxMain
public static void main(String... args)
{
+ execNT() ; exit(0) ;
+
+
+
if ( false ) SystemTDB.setFileMode(FileMode.direct) ;
initFS() ;
@@ -105,6 +119,55 @@ public class TxMain
exit(0) ;
}
+ private static void execNT()
+ {
+ String dir = "DB" ;
+ FileOps.clearDirectory(dir) ;
+
+ DatasetGraphTDB dsg = TDBFactory.createDatasetGraph(dir) ;
+ BPlusTree index = BPlusTree.makeMem(20, 20, SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId) ;
+ RecordFactory recordFactory = new RecordFactory(SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId) ;
+ Index idx = index ;
+ //ObjectFile objectFile = FileFactory.createObjectFileMem() ;
+ ObjectFile objectFile = FileFactory.createObjectFileDisk("DB/N.jrnl") ;
+ NodeTable nt0 = dsg.getTripleTable().getNodeTupleTable().getNodeTable() ;
+
+ // Add to the base table.
+ Node node1 = NodeFactory.parseNode("<x>") ;
+ NodeId id_1 = nt0.getAllocateNodeId(node1) ;
+
+ // Set up the trans table.
+ int offset = (int)nt0.allocOffset().getId() ;
+ System.out.println("Offset = "+offset) ;
+ NodeTableTrans ntt = new NodeTableTrans(null, nt0, offset, idx, objectFile) ;
+ NodeTable nt = NodeTableInline.create(ntt) ;
+
+ Node node2 = NodeFactory.parseNode("<y>") ;
+ NodeId id_2 = nt.getAllocateNodeId(node2) ;
+ System.out.println("==> "+id_2) ;
+
+ Node node3 = NodeFactory.parseNode("123") ;
+ NodeId id_3 = nt.getAllocateNodeId(node3) ;
+ System.out.println("==> "+id_3) ;
+
+ Node n = nt.getNodeForNodeId(id_1) ;
+ System.out.println("1: ==> "+n) ;
+ n = nt.getNodeForNodeId(id_2) ;
+ System.out.println("2: ==> "+n) ;
+ n = nt.getNodeForNodeId(id_3) ;
+ System.out.println("3: ==> "+n) ;
+
+ NodeId x = nt.getNodeIdForNode(node2) ;
+ System.out.println("==> "+x) ;
+
+ System.out.println("Base: "+nt0.getNodeIdForNode(node1)) ;
+ System.out.println("Trans: "+nt.getNodeIdForNode(node1)) ;
+ System.out.println("Base: "+nt0.getNodeIdForNode(node2)) ;
+ System.out.println("Trans: "+nt.getNodeIdForNode(node2)) ;
+ System.out.println("Base: "+nt0.getNodeIdForNode(node3)) ;
+ System.out.println("Trans: "+nt.getNodeIdForNode(node3)) ;
+ }
+
private static void deconstruct(DatasetGraphTDB dsg)
{
/* Better:
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/factories/IndexFactoryBPlusTree.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/factories/IndexFactoryBPlusTree.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/factories/IndexFactoryBPlusTree.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/factories/IndexFactoryBPlusTree.java Wed Jun 29 14:54:35 2011
@@ -53,8 +53,8 @@ public class IndexFactoryBPlusTree imple
if ( params.getCalcBlockSize() > blockSize )
throw new TDBException("Calculated block size is greater than required size") ;
- BlockMgr blkMgrNodes = createBlockMgr(fileset, Names.bptExt1, blockSize) ;
- BlockMgr blkMgrRecords = createBlockMgr(fileset, Names.bptExt2, blockSize) ;
+ BlockMgr blkMgrNodes = createBlockMgr(fileset, Names.bptExtTree, blockSize) ;
+ BlockMgr blkMgrRecords = createBlockMgr(fileset, Names.bptExtRecords, blockSize) ;
return BPlusTree.create(params, blkMgrNodes, blkMgrRecords) ;
}
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTable.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTable.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTable.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTable.java Wed Jun 29 14:54:35 2011
@@ -34,6 +34,10 @@ public interface NodeTable extends Sync,
/** Iterate over all nodes (not necessarily fast). Does not include inlined NodeIds */
public Iterator<Pair<NodeId, Node>> all() ;
+
+ /** The offset needed to predicate allocation difference between peristent tables - internal function */
+ public NodeId allocOffset() ;
+
}
/*
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java Wed Jun 29 14:54:35 2011
@@ -165,6 +165,12 @@ public class NodeTableCache implements N
// ----
@Override
+ public NodeId allocOffset()
+ {
+ return baseTable.allocOffset() ;
+ }
+
+ @Override
public synchronized void close()
{
if ( baseTable == null )
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableInline.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableInline.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableInline.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableInline.java Wed Jun 29 14:54:35 2011
@@ -11,9 +11,9 @@ import com.hp.hpl.jena.graph.Node ;
import com.hp.hpl.jena.tdb.nodetable.NodeTable ;
import com.hp.hpl.jena.tdb.store.NodeId ;
-/** NodeTable wrapper to hanlde inline node ids.
+/** NodeTable wrapper to handle inline node ids.
* If a node can be made inline, then the underlying table never sees it.
- * If an inline Nodeid is seen, itis decoded and returned without
+ * If an inline Nodeid is seen, it is decoded and returned without
* the underlying table being called.
*/
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableLogger.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableLogger.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableLogger.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableLogger.java Wed Jun 29 14:54:35 2011
@@ -59,6 +59,14 @@ public class NodeTableLogger implements
}
@Override
+ public NodeId allocOffset()
+ {
+ NodeId nodeId = nodeTable.allocOffset() ;
+ info("allocOffset() => "+nodeId) ;
+ return nodeId ;
+ }
+
+ @Override
public Iterator<Pair<NodeId, Node>> all()
{
info("all()") ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableNative.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableNative.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableNative.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableNative.java Wed Jun 29 14:54:35 2011
@@ -177,6 +177,12 @@ public class NodeTableNative implements
}
}
+ @Override
+ public NodeId allocOffset()
+ {
+ return NodeId.create(getObjects().length()) ;
+ }
+
// Not synchronized
@Override
public Iterator<Pair<NodeId, Node>> all() { return all2() ; }
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableSink.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableSink.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableSink.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableSink.java Wed Jun 29 14:54:35 2011
@@ -45,6 +45,12 @@ public class NodeTableSink implements No
}
@Override
+ public NodeId allocOffset()
+ {
+ return NodeId.create(id) ;
+ }
+
+ @Override
public Iterator<Pair<NodeId, Node>> all()
{
return Iter.nullIterator() ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableWrapper.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableWrapper.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableWrapper.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableWrapper.java Wed Jun 29 14:54:35 2011
@@ -45,6 +45,13 @@ public class NodeTableWrapper implements
}
@Override
+ public NodeId allocOffset()
+ {
+ return nodeTable.allocOffset() ;
+ }
+
+
+ @Override
public Iterator<Pair<NodeId, Node>> all()
{
return nodeTable.all();
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java Wed Jun 29 14:54:35 2011
@@ -479,8 +479,8 @@ public class DatasetBuilderStd implement
// BlockMgr blkMgrNodes = BlockMgrFactory.create(fileset, Names.bptExt1, blockSize, readCacheSize, writeCacheSize) ;
// BlockMgr blkMgrRecords = BlockMgrFactory.create(fileset, Names.bptExt2, blockSize, readCacheSize, writeCacheSize) ;
- BlockMgr blkMgrNodes = blockMgrBuilderNodes.buildBlockMgr(fileset, Names.bptExt1, blockSize) ;
- BlockMgr blkMgrRecords = blockMgrBuilderRecords.buildBlockMgr(fileset, Names.bptExt2, blockSize) ;
+ BlockMgr blkMgrNodes = blockMgrBuilderNodes.buildBlockMgr(fileset, Names.bptExtTree, blockSize) ;
+ BlockMgr blkMgrRecords = blockMgrBuilderRecords.buildBlockMgr(fileset, Names.bptExtRecords, blockSize) ;
return BPlusTree.create(params, blkMgrNodes, blkMgrRecords) ;
}
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdIndexBuild.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdIndexBuild.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdIndexBuild.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdIndexBuild.java Wed Jun 29 14:54:35 2011
@@ -115,8 +115,8 @@ public class CmdIndexBuild
FileSet destination = new FileSet(location, indexName) ;
- BlockMgr blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExt1, blockSizeNodes, readCacheSize, writeCacheSize) ;
- BlockMgr blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExt2, blockSizeRecords, readCacheSize, writeCacheSize) ;
+ BlockMgr blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExtTree, blockSizeNodes, readCacheSize, writeCacheSize) ;
+ BlockMgr blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExtRecords, blockSizeRecords, readCacheSize, writeCacheSize) ;
int rowBlock = 1000 ;
Iterator<Record> iter = new RecordsFromInput(input, tupleLength, colMap, rowBlock) ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/Names.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/Names.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/Names.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/Names.java Wed Jun 29 14:54:35 2011
@@ -19,8 +19,8 @@ public class Names
public static final String[] prefixIndexes = { primaryIndexPrefix } ;
/** B+Trees - nodes file and records file */
- public static final String bptExt1 = "idn" ;
- public static final String bptExt2 = "dat" ;
+ public static final String bptExtTree = "idn" ;
+ public static final String bptExtRecords = "dat" ;
/** BTrees - single file per tree */
public static final String btExt = "idx" ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java Wed Jun 29 14:54:35 2011
@@ -716,8 +716,8 @@ public class SetupTDB
}
BPlusTreeParams params = new BPlusTreeParams(order, factory) ;
- BlockMgr blkMgrNodes = BlockMgrFactory.create(fileset, Names.bptExt1, blockSize, readCacheSize, writeCacheSize) ;
- BlockMgr blkMgrRecords = BlockMgrFactory.create(fileset, Names.bptExt2, blockSize, readCacheSize, writeCacheSize) ;
+ BlockMgr blkMgrNodes = BlockMgrFactory.create(fileset, Names.bptExtTree, blockSize, readCacheSize, writeCacheSize) ;
+ BlockMgr blkMgrRecords = BlockMgrFactory.create(fileset, Names.bptExtRecords, blockSize, readCacheSize, writeCacheSize) ;
return BPlusTree.create(params, blkMgrNodes, blkMgrRecords) ;
}
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/tdb/CmdRewriteIndex.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/tdb/CmdRewriteIndex.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/tdb/CmdRewriteIndex.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/tdb/CmdRewriteIndex.java Wed Jun 29 14:54:35 2011
@@ -47,7 +47,7 @@ public class CmdRewriteIndex
System.exit(1) ;
}
- if ( FileOps.exists(dstLoc.getPath(indexName, Names.bptExt1)) )
+ if ( FileOps.exists(dstLoc.getPath(indexName, Names.bptExtTree)) )
{
System.err.println("Destination contains an index of that name") ;
System.exit(1) ;
@@ -104,8 +104,8 @@ public class CmdRewriteIndex
int blockSizeNodes = blockSize ;
int blockSizeRecords = blockSize ;
- blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExt1, blockSizeNodes, readCacheSize, writeCacheSize) ;
- blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExt2, blockSizeRecords, readCacheSize, writeCacheSize) ;
+ blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExtTree, blockSizeNodes, readCacheSize, writeCacheSize) ;
+ blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExtRecords, blockSizeRecords, readCacheSize, writeCacheSize) ;
iterator = bpt.iterator() ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/bplustree/TestBPlusTreeRewriter.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/bplustree/TestBPlusTreeRewriter.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/bplustree/TestBPlusTreeRewriter.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/bplustree/TestBPlusTreeRewriter.java Wed Jun 29 14:54:35 2011
@@ -66,9 +66,9 @@ public class TestBPlusTreeRewriter exten
FileSet destination = FileSet.mem() ;
// ---- Rewrite
// Write leaves to ...
- BlockMgr blkMgr1 = BlockMgrFactory.create(destination, Names.bptExt1, bptParams.getCalcBlockSize(), 10, 10) ;
+ BlockMgr blkMgr1 = BlockMgrFactory.create(destination, Names.bptExtTree, bptParams.getCalcBlockSize(), 10, 10) ;
// Write nodes to ...
- BlockMgr blkMgr2 = BlockMgrFactory.create(destination, Names.bptExt1, bptParams.getCalcBlockSize(), 10, 10) ;
+ BlockMgr blkMgr2 = BlockMgrFactory.create(destination, Names.bptExtTree, bptParams.getCalcBlockSize(), 10, 10) ;
BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(originaldata.iterator(), bptParams,
recordFactory, blkMgr1, blkMgr2) ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/store/TestGraphTDB.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/store/TestGraphTDB.java?rev=1141122&r1=1141121&r2=1141122&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/store/TestGraphTDB.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/store/TestGraphTDB.java Wed Jun 29 14:54:35 2011
@@ -10,6 +10,7 @@ import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.openjena.atlas.logging.Log ;
import com.hp.hpl.jena.graph.Graph;
import com.hp.hpl.jena.sparql.graph.AbstractTestGraph2 ;
@@ -42,7 +43,15 @@ public class TestGraphTDB extends Abstra
static Graph graph = null ;
@Before public void before()
{
- graph.getBulkUpdateHandler().removeAll() ;
+ try {
+ graph.getBulkUpdateHandler().removeAll() ;
+ } catch (Exception ex)
+ {
+ Log.warn(this, "before() : "+ex.getMessage(), ex) ;
+ // Problem - reset.
+ beforeClass() ;
+ }
+
}