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/07/26 14:19:12 UTC
svn commit: r1151072 - in
/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb:
base/block/Block.java index/TupleTable.java index/bplustree/BPTreeNode.java
index/bplustree/BPTreeNodeMgr.java
Author: andy
Date: Tue Jul 26 12:19:11 2011
New Revision: 1151072
URL: http://svn.apache.org/viewvc?rev=1151072&view=rev
Log:
reformat blocks on promotion if the underlying block changes.
Modified:
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/Block.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/TupleTable.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/bplustree/BPTreeNode.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/bplustree/BPTreeNodeMgr.java
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/Block.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/Block.java?rev=1151072&r1=1151071&r2=1151072&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/Block.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/Block.java Tue Jul 26 12:19:11 2011
@@ -6,8 +6,12 @@
package com.hp.hpl.jena.tdb.base.block;
+import java.io.ByteArrayOutputStream ;
+import java.io.PrintStream ;
import java.nio.ByteBuffer ;
+import org.openjena.atlas.lib.ByteBufferLib ;
+
// import tx.base.BlockRef ;
import com.hp.hpl.jena.tdb.base.page.Page ;
@@ -95,7 +99,16 @@ public final class Block
public String toString()
{
ByteBuffer bb = getByteBuffer() ;
- return String.format("Block: %d (posn=%d, limit=%d, cap=%d)", id, bb.position(), bb.limit(), bb.capacity()) ;
+ if ( true )
+ // Short form.
+ return String.format("Block: %d (posn=%d, limit=%d, cap=%d)", id, bb.position(), bb.limit(), bb.capacity()) ;
+ // Long form - with some bytes from the ByteBuffer.
+ ByteArrayOutputStream out = new ByteArrayOutputStream() ;
+ PrintStream x = new PrintStream(out) ;
+ ByteBufferLib.print(x, bb) ;
+ x.flush() ;
+ String str = out.toString() ;
+ return String.format("Block: %d %s", id, str) ;
}
/** Deep copy, including ByteBuffer contents. */
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/TupleTable.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/TupleTable.java?rev=1151072&r1=1151071&r2=1151072&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/TupleTable.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/TupleTable.java Tue Jul 26 12:19:11 2011
@@ -9,12 +9,8 @@ package com.hp.hpl.jena.tdb.index;
import static java.lang.String.format ;
-import java.io.FileOutputStream ;
-import java.io.IOException ;
-import java.io.OutputStream ;
import java.util.Iterator ;
-import org.openjena.atlas.io.IndentedWriter ;
import org.openjena.atlas.lib.Closeable ;
import org.openjena.atlas.lib.Sync ;
import org.openjena.atlas.lib.Tuple ;
@@ -22,7 +18,6 @@ import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import com.hp.hpl.jena.tdb.TDBException ;
-import com.hp.hpl.jena.tdb.index.bplustree.BPlusTree ;
import com.hp.hpl.jena.tdb.store.NodeId ;
/** A TupleTable is a set of TupleIndexes. The first TupleIndex is the "primary" index and must exist */
@@ -56,18 +51,6 @@ public class TupleTable implements Sync,
if ( tupleLen != t.size() )
throw new TDBException(format("Mismatch: inserting tuple of length %d into a table of tuples of length %d", t.size(), tupleLen)) ;
- x++ ;
- boolean thisOne = ( t.get(0).getId() == 0xD0 && t.get(1).getId() == 0x01 && t.get(2).getId() == 0x0C ) ;
-
- if ( thisOne )
- System.err.printf("Target: %s (%d)\n",t, x) ;
-
- if ( thisOne )
- {
- if ( ! indexes[0].find(t).hasNext() )
- System.err.printf("Absent[1]: @%d\n", x) ;
- }
-
for ( int i = 0 ; i < indexes.length ; i++ )
{
if ( indexes[i] == null ) continue ;
@@ -84,45 +67,31 @@ public class TupleTable implements Sync,
}
}
-
- if ( thisOne )
- added ++ ;
-
- if ( added > 0 ) // && thisOne )
- {
- if ( ! indexes[0].find(t).hasNext() )
- System.err.printf("Gone[2]: @%d\n", x) ;
- }
-
-
-
return true ;
}
protected void duplicate(Tuple<NodeId> t)
- {
- //System.err.printf("Duplicate on primary index: %s\n",t) ;
- }
+ { }
protected void unexpectedDuplicate(Tuple<NodeId> t, int i)
{
- System.err.printf("Duplicate on secondary index: %s\n",t) ;
- for ( TupleIndex index : indexes )
- {
- if ( index.find(t) != null )
- System.err.printf("%s: Present\n",index.getLabel()) ;
- else
- System.err.printf("%s: Absent\n",index.getLabel()) ;
- }
-
- try {
- OutputStream f = new FileOutputStream("LOG") ;
- IndentedWriter w = new IndentedWriter(f) ;
- ( (BPlusTree) ((TupleIndexRecord)indexes[i]).getRangeIndex() ).dump(w) ;
- w.flush() ;
- f.flush() ;
- f.close() ;
- } catch ( IOException ex ) {}
+// System.err.printf("Duplicate on secondary index: %s\n",t) ;
+// for ( TupleIndex index : indexes )
+// {
+// if ( index.find(t) != null )
+// System.err.printf("%s: Present\n",index.getLabel()) ;
+// else
+// System.err.printf("%s: Absent\n",index.getLabel()) ;
+// }
+//
+// try {
+// OutputStream f = new FileOutputStream("LOG") ;
+// IndentedWriter w = new IndentedWriter(f) ;
+// ( (BPlusTree) ((TupleIndexRecord)indexes[i]).getRangeIndex() ).dump(w) ;
+// w.flush() ;
+// f.flush() ;
+// f.close() ;
+// } catch ( IOException ex ) {}
}
/** Delete a tuple - return true if it was deleted, false if it didn't exist */
@@ -131,22 +100,14 @@ public class TupleTable implements Sync,
if ( tupleLen != t.size() )
throw new TDBException(format("Mismatch: deleting tuple of length %d from a table of tuples of length %d", t.size(), tupleLen)) ;
+ boolean rc = false ;
for ( int i = 0 ; i < indexes.length ; i++ )
{
if ( indexes[i] == null ) continue ;
// Use return boolean
- indexes[i].delete(t) ;
-// if ( ! indexes[i].delete(t) )
-// {
-// if ( i == 0 )
-// {
-// duplicate(t) ;
-// return false ;
-// }
-// throw new TDBException("Secondary index duplicate: "+t) ;
-// }
+ rc = indexes[i].delete(t) ;
}
- return true ;
+ return rc ;
}
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/bplustree/BPTreeNode.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/bplustree/BPTreeNode.java?rev=1151072&r1=1151071&r2=1151072&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/bplustree/BPTreeNode.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/bplustree/BPTreeNode.java Tue Jul 26 12:19:11 2011
@@ -128,6 +128,8 @@ public final class BPTreeNode extends BP
public void reset(Block block)
{
this.block = block ;
+ // reformat block (sets record and pointer buffers)
+ BPTreeNodeMgr.formatBPTreeNode(this, bpTree, block, isLeaf, count) ;
}
// [TxTDB:PATCH-UP] REMOVE
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/bplustree/BPTreeNodeMgr.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/bplustree/BPTreeNodeMgr.java?rev=1151072&r1=1151071&r2=1151072&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/bplustree/BPTreeNodeMgr.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/bplustree/BPTreeNodeMgr.java Tue Jul 26 12:19:11 2011
@@ -193,9 +193,9 @@ public final class BPTreeNodeMgr extends
return n ;
}
- static BPTreeNode formatBPTreeNode(BPTreeNode n, BPlusTree bTree, Block block, boolean leaf, int count)
+ static void formatBPTreeNode(BPTreeNode n, BPlusTree bpTree, Block block, boolean leaf, int count)
{
- BPlusTreeParams params = bTree.getParams() ;
+ BPlusTreeParams params = bpTree.getParams() ;
int ptrBuffLen = params.MaxPtr * params.getPtrLength() ;
// Only store the key part of records in a B+Tree block
@@ -248,7 +248,6 @@ public final class BPTreeNodeMgr extends
// Reset
byteBuffer.rewind() ;
- return n ;
}
static final void formatForRoot(BPTreeNode n, boolean asLeaf)