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/12/08 17:35:29 UTC
svn commit: r1211966 - in
/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb:
lib/TupleLib.java transaction/DatasetBuilderTxn.java
transaction/NodeTableTrans.java
Author: andy
Date: Thu Dec 8 16:35:29 2011
New Revision: 1211966
URL: http://svn.apache.org/viewvc?rev=1211966&view=rev
Log:
Use an in-memory object table for temporary space in a transaction.
Modified:
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/lib/TupleLib.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetBuilderTxn.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/lib/TupleLib.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/lib/TupleLib.java?rev=1211966&r1=1211965&r2=1211966&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/lib/TupleLib.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/lib/TupleLib.java Thu Dec 8 16:35:29 2011
@@ -26,6 +26,7 @@ import org.openjena.atlas.iterator.Iter
import org.openjena.atlas.iterator.Transform ;
import org.openjena.atlas.lib.Bytes ;
import org.openjena.atlas.lib.ColumnMap ;
+import org.openjena.atlas.lib.InternalErrorException ;
import org.openjena.atlas.lib.Tuple ;
@@ -117,12 +118,33 @@ public class TupleLib
private static Triple triple(NodeTable nodeTable, NodeId s, NodeId p, NodeId o)
{
+ if ( ! NodeId.isConcrete(s) )
+ throw new InternalErrorException("Invalid id for subject: "+fmt(s,p,o)) ;
+ if ( ! NodeId.isConcrete(p) )
+ throw new InternalErrorException("Invalid id for predicate: "+fmt(s,p,o)) ;
+ if ( ! NodeId.isConcrete(o) )
+ throw new InternalErrorException("Invalid id for object: "+fmt(s,p,o)) ;
+
Node sNode = nodeTable.getNodeForNodeId(s) ;
+ if ( sNode == null )
+ throw new InternalErrorException("Invalid id node for subject (null node): "+fmt(s,p,o)) ;
+
Node pNode = nodeTable.getNodeForNodeId(p) ;
+ if ( pNode == null )
+ throw new InternalErrorException("Invalid id node for predicate (null node): "+fmt(s,p,o)) ;
+
Node oNode = nodeTable.getNodeForNodeId(o) ;
+ if ( oNode == null )
+ throw new InternalErrorException("Invalid id node for object (null node): "+fmt(s,p,o)) ;
+
return new Triple(sNode, pNode, oNode) ;
}
+ private static String fmt(NodeId s, NodeId p, NodeId o)
+ {
+ return "("+s+", "+p+", "+o+")" ;
+ }
+
private static Quad quad(NodeTable nodeTable, Tuple<NodeId> tuple)
{
if ( tuple.size() != 4 )
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetBuilderTxn.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetBuilderTxn.java?rev=1211966&r1=1211965&r2=1211966&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetBuilderTxn.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetBuilderTxn.java Thu Dec 8 16:35:29 2011
@@ -124,10 +124,14 @@ public class DatasetBuilderTxn
Index idx = new IndexMap(recordFactory) ;
String objFilename = fsObjectFile.filename(Names.extNodeData+"-"+Names.extJournal) ;
ObjectFile objectFile ;
- if ( fsObjectFile.isMem() )
- objectFile = FileFactory.createObjectFileMem(objFilename) ;
- else
- objectFile = FileFactory.createObjectFileDisk(objFilename) ;
+
+
+// if ( fsObjectFile.isMem() )
+// objectFile = FileFactory.createObjectFileMem(objFilename) ;
+// else
+// objectFile = FileFactory.createObjectFileDisk(objFilename) ;
+ // EXPERIMENT
+ objectFile = FileFactory.createObjectFileMem(objFilename) ;
NodeTableTrans ntt = new NodeTableTrans(txn ,fsObjectFile.getBasename(), ntBase, idx, objectFile) ;
txn.addComponent(ntt) ;
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java?rev=1211966&r1=1211965&r2=1211966&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java Thu Dec 8 16:35:29 2011
@@ -65,7 +65,9 @@ public class NodeTableTrans implements N
this.txn = txn ;
this.base = sub ;
this.nodeIndex = nodeIndex ;
+ //objFile.truncate(0) ;
this.journalObjFile = objFile ;
+
this.label = label ;
// Show the way tables are wired up
//debug("NTT[%s #%s] %s", label, Integer.toHexString(hashCode()), sub) ;
@@ -81,7 +83,7 @@ public class NodeTableTrans implements N
{
if ( passthrough ) return base.getAllocateNodeId(node) ;
NodeId nodeId = getNodeIdForNode(node) ;
- if ( ! NodeId.doesNotExist(nodeId) )
+ if ( ! NodeId.isDoesNotExist(nodeId) )
return nodeId ;
// add to journal
nodeId = allocate(node) ;
@@ -93,7 +95,7 @@ public class NodeTableTrans implements N
{
if ( passthrough ) return base.getNodeIdForNode(node) ;
NodeId nodeId = nodeTableJournal.getNodeIdForNode(node) ;
- if ( ! NodeId.doesNotExist(nodeId) )
+ if ( ! NodeId.isDoesNotExist(nodeId) )
return mapFromJournal(nodeId) ;
nodeId = base.getNodeIdForNode(node) ;
return nodeId ;
@@ -152,6 +154,8 @@ public class NodeTableTrans implements N
@Override
public void begin(Transaction txn)
{
+ debug("%s begin", txn.getLabel()) ;
+
if ( this.txn.getTxnId() != txn.getTxnId() )
throw new TDBException(String.format("Different transactions: %s %s", this.txn.getLabel(), txn.getLabel())) ;
if ( passthrough )
@@ -176,7 +180,7 @@ public class NodeTableTrans implements N
System.err.println("journalStartOffset reset to zero") ;
journalObjFileStartOffset = 0 ;
journalObjFile.truncate(0) ;
- journalObjFile.sync() ;
+ //journalObjFile.sync() ;
}
}
offset += journalObjFileStartOffset ;