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/12 17:17:14 UTC
svn commit: r1213294 - in /incubator/jena: Jena2/JenaZip/trunk/
Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/
Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/lib/
Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/ Jena2...
Author: andy
Date: Mon Dec 12 16:17:13 2011
New Revision: 1213294
URL: http://svn.apache.org/viewvc?rev=1213294&view=rev
Log: (empty)
Modified:
incubator/jena/Jena2/JenaZip/trunk/BUILD
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileStorage.java
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/nodetable/NodeTableCache.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java
incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java
Modified: incubator/jena/Jena2/JenaZip/trunk/BUILD
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/JenaZip/trunk/BUILD?rev=1213294&r1=1213293&r2=1213294&view=diff
==============================================================================
--- incubator/jena/Jena2/JenaZip/trunk/BUILD (original)
+++ incubator/jena/Jena2/JenaZip/trunk/BUILD Mon Dec 12 16:17:13 2011
@@ -112,6 +112,6 @@ svn co https://svn.apache.org/repos/asf/
-------------------------------------------------------
-Please do hestiate in contacting the Jena developers:
+If you have any questions, please do not hesitate in contacting the Jena project:
jena-users@incubator.apache.org
jena-dev@incubator.apache.org
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileStorage.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileStorage.java?rev=1213294&r1=1213293&r2=1213294&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileStorage.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileStorage.java Mon Dec 12 16:17:13 2011
@@ -113,20 +113,23 @@ public class ObjectFileStorage implement
if ( writeBuffer.position()+spaceNeeded > writeBuffer.capacity() )
{
long x = rawWrite(bb) ;
- log("W -> 0x%X", x);
+ if ( logging )
+ log("W -> 0x%X", x);
return x ;
}
long loc = writeBuffer.position()+filesize ;
writeBuffer.putInt(len) ;
writeBuffer.put(bb) ;
- log("W -> 0x%X", loc);
+ if ( logging )
+ log("W -> 0x%X", loc);
return loc ;
}
private long rawWrite(ByteBuffer bb)
{
- log("RW %s", bb) ;
+ if ( logging )
+ log("RW %s", bb) ;
int len = bb.limit() - bb.position() ;
lengthBuffer.rewind() ;
lengthBuffer.putInt(len) ;
@@ -139,8 +142,10 @@ public class ObjectFileStorage implement
filesize = filesize+x+SizeOfInt ;
if ( logging )
+ {
log("Posn: %d", file.position());
- log("RW ->0x%X",location) ;
+ log("RW ->0x%X",location) ;
+ }
return location ;
}
@@ -182,14 +187,17 @@ public class ObjectFileStorage implement
ByteBuffer bb = writeBuffer.slice() ;
allocBlock = new Block(allocLocation, bb) ;
- //log.info("AW:"+state()+"->0x"+Long.toHexString(allocLocation)) ;
+
+ if ( logging )
+ log("AW: %s->0x%X", state(), allocLocation) ;
return allocBlock ;
}
@Override
public void completeWrite(Block block)
{
- log("CW: %s @0x%X",block, allocLocation) ;
+ if ( logging )
+ log("CW: %s @0x%X",block, allocLocation) ;
if ( ! inAllocWrite )
throw new FileException("Not in the process of an allocated write operation pair") ;
if ( allocBlock != null && ( allocBlock.getByteBuffer() != block.getByteBuffer() ) )
@@ -220,15 +228,29 @@ public class ObjectFileStorage implement
private void flushOutputBuffer()
{
- log("Flush") ;
+ if ( logging )
+ log("Flush") ;
+
if ( writeBuffer == null ) return ;
if ( writeBuffer.position() == 0 ) return ;
+
+ if ( false )
+ {
+ String x = getLabel() ;
+ if ( x.contains("nodes") )
+ {
+ long x1 = filesize ;
+ long x2 = writeBuffer.position() ;
+ long x3 = x1 + x2 ;
+ System.out.printf("Flush(%s) : %d/0x%04X (%d/0x%04X) %d/0x%04X\n", getLabel(), x1, x1, x2, x2, x3, x3) ;
+ }
+ }
+
long location = filesize ;
writeBuffer.flip();
int x = file.write(writeBuffer) ;
filesize += x ;
writeBuffer.clear() ;
- log("Flush") ;
}
@Override
@@ -253,7 +275,8 @@ public class ObjectFileStorage implement
@Override
public ByteBuffer read(long loc)
{
- log("R(0x%X)", loc) ;
+ if ( logging )
+ log("R(0x%X)", loc) ;
if ( inAllocWrite )
throw new FileException("In the middle of an alloc-write") ;
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=1213294&r1=1213293&r2=1213294&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 Mon Dec 12 16:17:13 2011
@@ -131,7 +131,10 @@ public class TupleLib
Node pNode = nodeTable.getNodeForNodeId(p) ;
if ( pNode == null )
+ {
+ nodeTable.getNodeForNodeId(p) ;
throw new InternalErrorException("Invalid id node for predicate (null node): "+fmt(s,p,o)) ;
+ }
Node oNode = nodeTable.getNodeForNodeId(o) ;
if ( oNode == null )
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java?rev=1213294&r1=1213293&r2=1213294&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java Mon Dec 12 16:17:13 2011
@@ -93,7 +93,7 @@ public class NodeTableCache implements N
synchronized (lock)
{
- Node n = cacheLookup(id) ; // Includes known to not exist
+ Node n = cacheLookup(id) ;
if ( n != null )
return n ;
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=1213294&r1=1213293&r2=1213294&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 Mon Dec 12 16:17:13 2011
@@ -100,6 +100,18 @@ public class NodeTableTrans implements N
return nodeId ;
}
+ @Override
+ public Node getNodeForNodeId(NodeId 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 ;
+ }
+
/** Convert from a id to the id in the "journal" file */
private NodeId mapToJournal(NodeId id)
{
@@ -120,18 +132,6 @@ public class NodeTableTrans implements N
return NodeId.create(id.getId()+offset) ;
}
- @Override
- public Node getNodeForNodeId(NodeId 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)
{
NodeId nodeId = nodeTableJournal.getAllocateNodeId(node) ;
@@ -194,15 +194,30 @@ public class NodeTableTrans implements N
this.nodeTableJournal = NodeTableInline.create(nodeTableJournal) ;
}
+ static final boolean APPEND_LOG = false ;
+
/** Copy from the journal file to the real file */
/*package*/ void append()
{
//debug(">> append: %s",label) ;
// Assumes all() is in order from low to high.
+
+ if ( APPEND_LOG )
+ System.out.printf(">> append: %s %s %d/0x%04X\n",label, base.allocOffset(), journalObjFile.length(), journalObjFile.length()) ;
+
Iterator<Pair<NodeId, Node>> iter = nodeTableJournal.all() ;
+ Pair<NodeId, Node> firstPair = null ;
+ Pair<NodeId, Node> lastPair = null ;
+
+
for ( ; iter.hasNext() ; )
{
Pair<NodeId, Node> x = iter.next() ;
+
+ if ( firstPair == null )
+ firstPair = x ;
+ lastPair = x ;
+
NodeId nodeId = x.getLeft() ;
Node node = x.getRight() ;
//debug("append: %s -> %s", x, mapFromJournal(nodeId)) ;
@@ -219,6 +234,14 @@ public class NodeTableTrans implements N
throw new TDBException(msg) ;
}
}
+
+ if ( APPEND_LOG )
+ {
+ System.out.printf("+ First: %s -> %s\n", firstPair.car(), mapFromJournal(firstPair.car())) ;
+ System.out.printf("+ Last: %s -> %s\n", lastPair.car(), mapFromJournal(lastPair.car())) ;
+ System.out.printf("+ New base: %s\n", base.allocOffset()) ;
+ }
+
//debug("<< append: %s",label) ;
}
@@ -302,16 +325,16 @@ public class NodeTableTrans implements N
return ;
//debug("writeNodeJournal: (base alloc before) %s", base.allocOffset()) ;
- append() ;
+ append() ; // Calls all() which does a buffer flish.
//debug("writeNodeJournal: (base alloc after) %s", base.allocOffset()) ;
//debug("writeNodeJournal: (nodeTableJournal) %s", nodeTableJournal.allocOffset()) ;
// Reset (in case we use this again)
nodeIndex.clear() ;
// Fixes nodeTableJournal
- journalObjFile.truncate(journalObjFileStartOffset) ;
+ journalObjFile.truncate(journalObjFileStartOffset) ; // Side effect is a buffer flush.
//journalObjFile.sync() ;
- journalObjFile.close() ;
+ journalObjFile.close() ; // Side effect is a buffer flush.
journalObjFile = null ;
base.sync() ;
offset = -99 ; // base.allocOffset().getId() ; // Will be invalid as we may write through to the base table later.
Modified: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java?rev=1213294&r1=1213293&r2=1213294&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java (original)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java Mon Dec 12 16:17:13 2011
@@ -115,7 +115,7 @@ public class Jena163_TDBDifferentIds
static {
// Clearup !!!!!!!!!!!!!
TransactionManager.DEBUG = inlineProgress ;
- ObjectFileStorage.logging = inlineProgress ;
+ //ObjectFileStorage.logging = true ;
FileBase.DEBUG = inlineProgress ;
NodeTableTrans.FIXUP = true ;
// See also log4j.properties.
@@ -237,6 +237,8 @@ public class Jena163_TDBDifferentIds
return null ;
} catch (RuntimeException ex)
{
+ System.out.flush() ;
+ System.err.println() ;
ex.printStackTrace(System.err) ;
if ( dsg != null )
{
@@ -245,6 +247,7 @@ public class Jena163_TDBDifferentIds
txn("E", dsg) ;
dsg = null ;
}
+ System.exit(2) ;
return null ;
}
finally { doneSignal.countDown(); }