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/27 11:03:27 UTC
svn commit: r1128205 - in /incubator/jena/Experimental/TxTDB/trunk/src:
main/java/com/hp/hpl/jena/tdb/base/ main/java/com/hp/hpl/jena/tdb/base/block/
main/java/com/hp/hpl/jena/tdb/base/objectfile/
test/java/com/hp/hpl/jena/tdb/base/file/
Author: andy
Date: Fri May 27 09:03:27 2011
New Revision: 1128205
URL: http://svn.apache.org/viewvc?rev=1128205&view=rev
Log: (empty)
Added:
incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/AbstractTestStringFile.java (with props)
incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFileDisk.java (contents, props changed)
- copied, changed from r1127810, incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFile.java
incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFileMem.java (with props)
Removed:
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/UnitMgr.java
incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFile.java
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/base/objectfile/ObjectFileMem.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/StringFile.java
incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TS_File.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=1128205&r1=1128204&r2=1128205&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 Fri May 27 09:03:27 2011
@@ -96,7 +96,8 @@ public final class Block
@Override
public String toString()
{
- return "Block: "+id+" : Length: "+byteBuffer.capacity() ;
+ ByteBuffer bb = getByteBuffer() ;
+ return String.format("Block: %d : (posn=%d, limit=%d, cap=%d)", id, bb.position(), bb.limit(), bb.capacity()) ;
}
public Block replicate()
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileMem.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileMem.java?rev=1128205&r1=1128204&r2=1128205&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileMem.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileMem.java Fri May 27 09:03:27 2011
@@ -92,9 +92,8 @@ public class ObjectFileMem implements Ob
@Override
public void completeWrite(Block block)
{
- if ( block.getId() != buffers.size() )
+ if ( block.getId() != buffers.size()-1 )
throw new StorageException() ;
-
write(block.getId(), block.getByteBuffer()) ;
}
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/StringFile.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/StringFile.java?rev=1128205&r1=1128204&r2=1128205&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/StringFile.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/StringFile.java Fri May 27 09:03:27 2011
@@ -39,6 +39,7 @@ public class StringFile implements Sync,
str = compress(str) ;
Block block = file.allocWrite(4*str.length()) ;
int len = Bytes.toByteBuffer(str, block.getByteBuffer()) ;
+ block.getByteBuffer().flip() ;
file.completeWrite(block) ;
return block.getId() ;
}
Added: incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/AbstractTestStringFile.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/AbstractTestStringFile.java?rev=1128205&view=auto
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/AbstractTestStringFile.java (added)
+++ incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/AbstractTestStringFile.java Fri May 27 09:03:27 2011
@@ -0,0 +1,162 @@
+/*
+ * (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * All rights reserved.
+ * [See end of file]
+ */
+
+package com.hp.hpl.jena.tdb.base.file;
+
+import org.junit.After ;
+import org.junit.Before ;
+import org.junit.Test ;
+import org.openjena.atlas.junit.BaseTest ;
+
+import com.hp.hpl.jena.tdb.base.objectfile.StringFile ;
+
+public abstract class AbstractTestStringFile extends BaseTest
+{
+ StringFile f = null ;
+
+ @Before public void setup() { f = createStringFile() ; }
+ @After public void teardown() { removeStringFile(f) ; }
+
+ protected abstract StringFile createStringFile() ;
+ protected abstract void removeStringFile(StringFile f) ;
+
+ @Test public void object_file_01()
+ {
+ String x1 = "abc" ;
+ long id1 = f.write(x1) ;
+ test(id1, x1) ;
+ test(0, x1) ;
+ }
+
+ @Test public void object_file_02()
+ {
+ String x1 = "" ;
+
+ long id1 = f.write(x1) ;
+ test(id1, x1) ;
+ test(0, x1) ;
+ }
+
+ @Test public void object_file_03()
+ {
+ String x1 = "abbbbbbc" ;
+ String x2 = "deeeef" ;
+
+ long id1 = f.write(x1) ;
+ long id2 = f.write(x2) ;
+
+ assertNotEquals("Node Ids", id1, id2) ;
+
+ test(id1, x1) ;
+ test(id2, x2) ;
+ test(0, x1) ;
+ }
+
+ @Test public void object_file_04()
+ {
+ String x1 = "abbbbbbc" ;
+ String x2 = "deeeef" ;
+
+ long id1 = f.write(x1) ;
+ long id2 = f.write(x2) ;
+ // Read in opposite order
+ test(id2, x2) ;
+ test(id1, x1) ;
+ }
+
+ @Test public void object_file_05()
+ {
+ String x = "å«åå
µæ³" ;
+
+ long id = f.write(x) ;
+ test(0, x) ;
+ }
+
+ @Test public void object_file_06()
+ {
+ String x1 = "abbbbbbc" ;
+ String x2 = "å«åå
µæ³" ;
+
+ long id1 = f.write(x1) ;
+ f.flush() ;
+ long id2 = f.write(x2) ;
+ // No flush.
+
+ assertNotEquals("Node Ids", id1, id2) ;
+
+ String z = f.read(id2) ;
+
+ test(id2, x2) ;
+ test(id1, x1) ;
+ test(0, x1) ;
+ }
+
+ @Test public void object_file_07()
+ {
+ String x1 = "abbbbbbc" ;
+ String x2 = "å«åå
µæ³" ;
+
+ long id1 = f.write(x1) ;
+ long id2 = f.write(x2) ;
+ f.flush() ;
+
+ assertNotEquals("Node Ids", id1, id2) ;
+
+ test(id2, x2) ;
+ test(id1, x1) ;
+ test(0, x1) ;
+ }
+
+ @Test public void object_file_08()
+ {
+ String x1 = "abbbbbbc" ;
+ String x2 = "å«åå
µæ³" ;
+
+ long id1 = f.write(x1) ;
+ f.flush() ;
+ long id2 = f.write(x2) ;
+ f.flush() ;
+
+ assertNotEquals("Node Ids", id1, id2) ;
+
+ test(id2, x2) ;
+ test(id1, x1) ;
+ test(0, x1) ;
+ }
+
+ private void test(long id, String x)
+ {
+ String y = f.read(id) ;
+ assertEquals(x, y) ;
+ }
+}
+
+/*
+ * (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
\ No newline at end of file
Propchange: incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/AbstractTestStringFile.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TS_File.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TS_File.java?rev=1128205&r1=1128204&r2=1128205&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TS_File.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TS_File.java Fri May 27 09:03:27 2011
@@ -15,7 +15,8 @@ import org.junit.runners.Suite;
TestMetaFile.class
, TestChannelMem.class
, TestChannelFile.class
- , TestStringFile.class
+ , TestStringFileMem.class
+ , TestStringFileDisk.class
, TestBlockAccessMem.class
, TestBlockAccessByteArray.class
, TestBlockAccessDirect.class
Copied: incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFileDisk.java (from r1127810, incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFile.java)
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFileDisk.java?p2=incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFileDisk.java&p1=incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFile.java&r1=1127810&r2=1128205&rev=1128205&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFile.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFileDisk.java Fri May 27 09:03:27 2011
@@ -1,5 +1,6 @@
/*
* (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * (c) Copyright 2011 Epimorphics Ltd.
* All rights reserved.
* [See end of file]
*/
@@ -7,111 +8,37 @@
package com.hp.hpl.jena.tdb.base.file;
import static org.openjena.atlas.lib.FileOps.clearDirectory ;
-import org.junit.After ;
-import org.junit.Before ;
-import org.junit.Test;
-import org.openjena.atlas.junit.BaseTest ;
+import org.openjena.atlas.lib.FileOps ;
-import com.hp.hpl.jena.tdb.ConfigTest;
-import com.hp.hpl.jena.tdb.base.objectfile.StringFile;
+import com.hp.hpl.jena.tdb.ConfigTest ;
+import com.hp.hpl.jena.tdb.base.objectfile.StringFile ;
-public class TestStringFile extends BaseTest
+public class TestStringFileDisk extends AbstractTestStringFile
{
- StringFile f = null ;
- @Before public void setup()
- {
- String dir = ConfigTest.getTestingDir() ;
- clearDirectory(dir) ;
- Location loc = new Location(dir) ;
- f = FileFactory.createStringFileDisk(loc.getPath("xyz", "node")) ;
- }
-
- @After public void teardown() { f.close() ; f = null ; }
-
- @Test public void object_file_1()
- {
- String x1 = "abbbbbbc" ;
- String x2 = "å«åå
µæ³" ;
-
- long id1 = f.write(x1) ;
- long id2 = f.write(x2) ;
-
- assertNotEquals("Node Ids", id1, id2) ;
-
- test(id2, x2) ;
- test(id1, x1) ;
- test(0, x1) ;
-// String y2 = f.read(id2) ;
-// assertEquals("x2",x2, y2) ;
-//
-// String y1 = f.read(id1) ;
-// assertEquals("x1", x1, y1) ;
-//
-// String y1a = f.read(0) ;
-// assertEquals("x1a", x1, y1) ;
- }
+ String fn = null ;
- @Test public void object_file_2()
+ @Override
+ protected StringFile createStringFile()
{
- String x1 = "abbbbbbc" ;
- String x2 = "å«åå
µæ³" ;
-
- long id1 = f.write(x1) ;
- f.flush() ;
- long id2 = f.write(x2) ;
- // No flush.
-
- assertNotEquals("Node Ids", id1, id2) ;
-
- String z = f.read(id2) ;
-
- test(id2, x2) ;
- test(id1, x1) ;
- test(0, x1) ;
- }
-
- @Test public void object_file_3()
- {
- String x1 = "abbbbbbc" ;
- String x2 = "å«åå
µæ³" ;
-
- long id1 = f.write(x1) ;
- long id2 = f.write(x2) ;
- f.flush() ;
-
- assertNotEquals("Node Ids", id1, id2) ;
-
- test(id2, x2) ;
- test(id1, x1) ;
- test(0, x1) ;
- }
-
- @Test public void object_file_4()
- {
- String x1 = "abbbbbbc" ;
- String x2 = "å«åå
µæ³" ;
-
- long id1 = f.write(x1) ;
- f.flush() ;
- long id2 = f.write(x2) ;
- f.flush() ;
-
- assertNotEquals("Node Ids", id1, id2) ;
-
- test(id2, x2) ;
- test(id1, x1) ;
- test(0, x1) ;
+ String dir = ConfigTest.getTestingDir() ;
+ clearDirectory(dir) ;
+ Location loc = new Location(dir) ;
+ fn = loc.getPath("xyz", "node") ;
+ FileOps.delete(fn) ;
+ return FileFactory.createStringFileDisk(fn) ;
}
- private void test(long id, String x)
+ @Override
+ protected void removeStringFile(StringFile f)
{
- String y = f.read(id) ;
- assertEquals(x, y) ;
+ f.close() ;
+ FileOps.delete(fn) ;
}
}
/*
* (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * (c) Copyright 2011 Epimorphics Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Propchange: incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFileDisk.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFileMem.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFileMem.java?rev=1128205&view=auto
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFileMem.java (added)
+++ incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFileMem.java Fri May 27 09:03:27 2011
@@ -0,0 +1,52 @@
+/*
+ * (c) Copyright 2011 Epimorphics Ltd.
+ * All rights reserved.
+ * [See end of file]
+ */
+
+package com.hp.hpl.jena.tdb.base.file;
+
+import com.hp.hpl.jena.tdb.base.objectfile.StringFile ;
+
+public class TestStringFileMem extends AbstractTestStringFile
+{
+
+ @Override
+ protected StringFile createStringFile()
+ {
+ return FileFactory.createStringFileMem() ;
+ }
+
+ @Override
+ protected void removeStringFile(StringFile f)
+ {
+ f.close() ;
+ }
+}
+
+/*
+ * (c) Copyright 2011 Epimorphics Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
\ No newline at end of file
Propchange: incubator/jena/Experimental/TxTDB/trunk/src/test/java/com/hp/hpl/jena/tdb/base/file/TestStringFileMem.java
------------------------------------------------------------------------------
svn:mime-type = text/plain