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/05/23 13:16:11 UTC
svn commit: r1126436 - in /incubator/jena/Experimental/TxTDB/trunk:
src-dev/tx/ src/main/java/com/hp/hpl/jena/tdb/base/block/
src/test/java/com/hp/hpl/jena/tdb/index/bplustree/
src/test/java/com/hp/hpl/jena/tdb/index/ext/
Author: andy
Date: Mon May 23 11:16:10 2011
New Revision: 1126436
URL: http://svn.apache.org/viewvc?rev=1126436&view=rev
Log: (empty)
Modified:
incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/BlockMgrFactory.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/BlockMgrTracker.java
incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/bplustree/TestBPTreeRecords.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/index/ext/TestExtHash.java
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=1126436&r1=1126435&r2=1126436&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java Mon May 23 11:16:10 2011
@@ -87,17 +87,36 @@ public class TxMain
public static void test()
{
+ BlockMgrFactory.AddTracker = false ;
+
//int[] keys = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int[] vals = {9,8,7,6,5,4,3,2,1,0};
- RangeIndex rIndex = makeRangeIndex(2) ;
+
+ //RangeIndex rIndex = makeRangeIndex(2) ;
+ BPlusTree bpt = BPlusTree.makeMem(2, 2, RecordLib.TestRecordLength, 0) ;
+
+
+ if ( false )
+ {
+ BlockMgr mgr = bpt.getRecordsMgr().getBlockMgr() ;
+ mgr = BlockMgrFactory.tracker(mgr) ;
+ mgr = new BlockMgrLogger("ABC", mgr, true) ;
+ bpt = BPlusTree.attach(bpt.getParams(), bpt.getNodeManager().getBlockMgr(), mgr) ;
+ }
+ else
+ {
+ bpt = BPlusTree.addTracking(bpt) ;
+ }
+ RangeIndex rIndex = bpt ;
+
// BPlusTreeParams.CheckingNode = true ;
// BPlusTreeParams.CheckingTree = true ;
for ( int v : vals )
{
Record r = intToRecord(v, rIndex.getRecordFactory()) ;
- if ( v == 5 )
+ if ( false && v == 5 )
{
BPlusTreeParams.Logging = true ;
Log.enable(BPTreeNode.class.getName(), "ALL") ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/BlockMgrFactory.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/BlockMgrFactory.java?rev=1126436&r1=1126435&r2=1126436&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/BlockMgrFactory.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/BlockMgrFactory.java Mon May 23 11:16:10 2011
@@ -20,7 +20,7 @@ import com.hp.hpl.jena.tdb.sys.SystemTDB
public class BlockMgrFactory
{
- public final static boolean AddTracker = true ;
+ public /*final*/ static boolean AddTracker = true ;
public static BlockMgr tracker(BlockMgr blockMgr)
{
if ( blockMgr instanceof BlockMgrTracker ) return blockMgr ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/BlockMgrTracker.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/BlockMgrTracker.java?rev=1126436&r1=1126435&r2=1126436&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/BlockMgrTracker.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/block/BlockMgrTracker.java Mon May 23 11:16:10 2011
@@ -26,7 +26,6 @@ public class BlockMgrTracker /*extends B
static enum Action { Alloc, Promote, GetRead, GetWrite, Write, Release, Free, IterRead, BeginRead, EndRead, BeginUpdate, EndUpdate}
static final Integer NoId = Integer.valueOf(-9) ;
-
// Don't inherit BlockMgrWrapper to make sure this class caches everything.
// XXX Issue: two block with same id but different ByteBuffers --> in someway, don't
@@ -155,10 +154,14 @@ public class BlockMgrTracker /*extends B
if ( ! activeWriteBlocks.contains(id) && ! activeReadBlocks.contains(id) )
error(Promote, id+" is not an active block") ;
-
- activeReadBlocks.remove(id) ;
- // Still on read blocks?
- activeWriteBlocks.add(id) ;
+ // Promote read uses of this block.
+ // Leave iterator reads alone.
+ if ( activeReadBlocks.contains(id) )
+ {
+ long x = activeReadBlocks.count(id) ;
+ activeReadBlocks.removeAll(id) ;
+ activeWriteBlocks.add(id, x) ;
+ }
}
return blockMgr.promote(block) ;
}
@@ -175,9 +178,10 @@ public class BlockMgrTracker /*extends B
if ( ! activeReadBlocks.contains(id) && ! activeIterBlocks.contains(id) && ! activeWriteBlocks.contains(id) )
error(Release, id+" is not an active block") ;
- // ???????????????????????
activeReadBlocks.remove(block.getId()) ;
activeIterBlocks.remove(block.getId()) ;
+
+ // This seems to need removeAll - is that acceptable?
activeWriteBlocks.remove(block.getId()) ;
}
blockMgr.release(block) ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/bplustree/TestBPTreeRecords.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/bplustree/TestBPTreeRecords.java?rev=1126436&r1=1126435&r2=1126436&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/bplustree/TestBPTreeRecords.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/bplustree/TestBPTreeRecords.java Mon May 23 11:16:10 2011
@@ -6,7 +6,9 @@
package com.hp.hpl.jena.tdb.index.bplustree;
+import org.junit.After ;
import org.junit.AfterClass;
+import org.junit.Before ;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openjena.atlas.junit.BaseTest ;
@@ -68,16 +70,17 @@ public class TestBPTreeRecords extends B
BPlusTreeParams.CheckingTree = oldCheckingBTree ;
}
-// @Before public void before() {}
-// @After public void after() {}
-
@Test public void bpt_records_1()
{
BPTreeRecords bpr = make() ;
fill(bpr) ;
check(bpr) ;
+ bpr.release() ;
}
+ @Before public void before() { blkMgrRecords.beginUpdate() ; }
+ @After public void after() { blkMgrRecords.endUpdate() ; }
+
@Test public void bpt_records_2()
{
@@ -90,6 +93,8 @@ public class TestBPTreeRecords extends B
assertEquals(s, z.getCount()+bpr.getCount()) ;
check(bpr) ;
check((BPTreeRecords)z) ;
+ bpr.release() ;
+ z.release() ;
}
@Test public void bpt_records_3()
@@ -98,6 +103,7 @@ public class TestBPTreeRecords extends B
for ( int i = 0 ; bpr.getCount() < bpr.getMaxSize() ; i++ )
insert(bpr, (i+0x20)) ;
check(bpr) ;
+ bpr.release() ;
}
@Test public void bpt_records_4()
@@ -106,6 +112,7 @@ public class TestBPTreeRecords extends B
for ( int i = bpr.getMaxSize()-1 ; i >= 0 ; i-- )
insert(bpr, i+0x20) ;
check(bpr) ;
+ bpr.release() ;
}
@Test public void bpt_records_5()
@@ -131,6 +138,8 @@ public class TestBPTreeRecords extends B
bpr.internalDelete(bpr.getHighRecord()) ;
assertEquals(N-4, bpr.getCount()) ;
check(bpr) ;
+
+ bpr.release() ;
}
@Test public void bpt_records_6()
@@ -152,7 +161,8 @@ public class TestBPTreeRecords extends B
r = bpr.getHighRecord() ;
r2 = search(bpr, r) ;
assertTrue(Record.keyEQ(r, r2)) ;
-
+
+ bpr.release() ;
}
@Test public void bpt_shift_1()
@@ -166,6 +176,10 @@ public class TestBPTreeRecords extends B
//assertTrue(Record.keyEQ(r, RecordTestLib.intToRecord(10))) ;
contains(bpr1) ;
contains(bpr2, 10) ;
+
+ bpr1.release() ;
+ bpr2.release() ;
+
}
@Test public void bpt_shift_2()
@@ -179,6 +193,8 @@ public class TestBPTreeRecords extends B
assertTrue(Record.keyEQ(r, RecordLib.intToRecord(10))) ;
contains(bpr1) ;
contains(bpr2, 10) ;
+ bpr1.release() ;
+ bpr2.release() ;
}
@Test public void bpt_shift_3()
@@ -194,6 +210,8 @@ public class TestBPTreeRecords extends B
assertTrue(r+" != "+RecordLib.intToRecord(10), Record.keyEQ(r, RecordLib.intToRecord(10))) ;
contains(bpr1, 10) ;
contains(bpr2, 20, 99) ;
+ bpr1.release() ;
+ bpr2.release() ;
}
@Test public void bpt_shift_4()
@@ -209,6 +227,8 @@ public class TestBPTreeRecords extends B
contains(bpr1, 20) ;
contains(bpr2, 5, 10) ;
+ bpr1.release() ;
+ bpr2.release() ;
}
@Test public void bpt_merge_1()
@@ -223,6 +243,8 @@ public class TestBPTreeRecords extends B
contains(bpr1, 10, 20, 99) ;
contains(bpr2) ;
assertSame(bpr1, bpr3) ;
+ bpr1.release() ;
+ bpr2.release() ;
}
@Test public void bpt_merge_2()
@@ -237,6 +259,8 @@ public class TestBPTreeRecords extends B
contains(bpr1) ;
contains(bpr2, 5, 10, 20) ;
assertSame(bpr2, bpr3) ;
+ bpr1.release() ;
+ bpr2.release() ;
}
private static void check(BPTreeRecords bpr)
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=1126436&r1=1126435&r2=1126436&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 Mon May 23 11:16:10 2011
@@ -10,6 +10,8 @@ import java.util.ArrayList ;
import java.util.Iterator ;
import java.util.List ;
+import org.junit.AfterClass ;
+import org.junit.BeforeClass ;
import org.junit.Test ;
import org.openjena.atlas.iterator.Iter ;
import org.openjena.atlas.junit.BaseTest ;
@@ -20,11 +22,6 @@ import com.hp.hpl.jena.tdb.base.block.Bl
import com.hp.hpl.jena.tdb.base.file.FileSet ;
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.bplustree.BPTreeException ;
-import com.hp.hpl.jena.tdb.index.bplustree.BPlusTree ;
-import com.hp.hpl.jena.tdb.index.bplustree.BPlusTreeParams ;
-import com.hp.hpl.jena.tdb.index.bplustree.BPlusTreeRewriter ;
-import com.hp.hpl.jena.tdb.index.bplustree.BPlusTreeRewriterUtils ;
import com.hp.hpl.jena.tdb.sys.Names ;
import com.hp.hpl.jena.tdb.sys.SetupTDB ;
@@ -36,6 +33,11 @@ public class TestBPlusTreeRewriter exten
static int ValueSize = 8 ;
static RecordFactory recordFactory = new RecordFactory(KeySize,ValueSize) ;
+ // The BPlusTreeRewriter works directly on storage.
+ static boolean b ;
+ @BeforeClass public static void beforeClass() { b = BlockMgrFactory.AddTracker ; BlockMgrFactory.AddTracker = false ; }
+ @AfterClass public static void afterClass() { BlockMgrFactory.AddTracker = b ;}
+
@Test public void bpt_rewrite_01() { runTest(2, 0) ; }
@Test public void bpt_rewrite_02() { runTest(3, 0) ; }
Modified: incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/ext/TestExtHash.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/ext/TestExtHash.java?rev=1126436&r1=1126435&r2=1126436&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/ext/TestExtHash.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/index/ext/TestExtHash.java Mon May 23 11:16:10 2011
@@ -21,16 +21,20 @@ import com.hp.hpl.jena.tdb.sys.SystemTDB
public class TestExtHash extends TestIndex
{
+ static boolean b ;
+
@BeforeClass static public void setup()
{
SystemTDB.NullOut = true ;
ExtHash.Checking = true ;
ExtHash.Logging = false ;
+ b = BlockMgrFactory.AddTracker ;
+ BlockMgrFactory.AddTracker = false ;
}
@AfterClass static public void teardown()
{
-
+ BlockMgrFactory.AddTracker = b ;
}
@Override