Search in sources :

Example 36 with Block

use of org.apache.jena.tdb.base.block.Block in project jena by apache.

the class AbstractTestObjectFile method objectfile_04.

@Test
public void objectfile_04() {
    Block block1 = file.allocWrite(10);
    fill(block1.getByteBuffer());
    file.completeWrite(block1);
    Block block2 = file.allocWrite(20);
    fill(block2.getByteBuffer());
    file.completeWrite(block2);
    long x1 = block1.getId();
    long x2 = block2.getId();
    assertFalse(x1 == x2);
}
Also used : Block(org.apache.jena.tdb.base.block.Block) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 37 with Block

use of org.apache.jena.tdb.base.block.Block in project jena by apache.

the class ObjectFileTrans method abortWrite.

@Override
public void abortWrite(Block block) {
    if (passthrough) {
        base.abortWrite(block);
        return;
    }
    block = new Block(block.getId() - otherAllocOffset, block.getByteBuffer());
    transObjects.abortWrite(block);
}
Also used : Block(org.apache.jena.tdb.base.block.Block)

Example 38 with Block

use of org.apache.jena.tdb.base.block.Block in project jena by apache.

the class AbstractTestBlockMgr method file03.

@Test
public void file03() {
    Block block = blockMgr.allocate(BlkSize);
    ByteBuffer bb = block.getByteBuffer();
    fill(bb, (byte) 2);
    long id = block.getId();
    blockMgr.write(block);
    blockMgr.release(block);
    Block block2 = blockMgr.getRead(id);
    ByteBuffer bb2 = block2.getByteBuffer();
    assertEquals(bb2.capacity(), BlkSize);
    assertEquals(bb2.get(0), (byte) 2);
    assertEquals(bb2.get(BlkSize - 1), (byte) 2);
    blockMgr.release(block2);
}
Also used : Block(org.apache.jena.tdb.base.block.Block) ByteBuffer(java.nio.ByteBuffer) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 39 with Block

use of org.apache.jena.tdb.base.block.Block in project jena by apache.

the class ObjectFileTrans method completeWrite.

@Override
public void completeWrite(Block block) {
    if (passthrough) {
        base.completeWrite(block);
        return;
    }
    block = new Block(block.getId() - otherAllocOffset, block.getByteBuffer());
    transObjects.completeWrite(block);
}
Also used : Block(org.apache.jena.tdb.base.block.Block)

Example 40 with Block

use of org.apache.jena.tdb.base.block.Block in project jena by apache.

the class AbstractTestBlockMgr method multiAccess01.

@Test
public void multiAccess01() {
    Block block1 = blockMgr.allocate(BlkSize);
    Block block2 = blockMgr.allocate(BlkSize);
    long id1 = block1.getId();
    long id2 = block2.getId();
    ByteBuffer bb1 = block1.getByteBuffer();
    ByteBuffer bb2 = block2.getByteBuffer();
    fill(bb1, (byte) 1);
    fill(bb2, (byte) 2);
    blockMgr.write(block1);
    blockMgr.write(block2);
    blockMgr.release(block1);
    blockMgr.release(block2);
    Block block3 = blockMgr.getRead(id1);
    Block block4 = blockMgr.getRead(id2);
    ByteBuffer bb_1 = block3.getByteBuffer();
    ByteBuffer bb_2 = block4.getByteBuffer();
    contains(bb_1, (byte) 1);
    contains(bb_2, (byte) 2);
    blockMgr.release(block3);
    blockMgr.release(block4);
}
Also used : Block(org.apache.jena.tdb.base.block.Block) ByteBuffer(java.nio.ByteBuffer) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Aggregations

Block (org.apache.jena.tdb.base.block.Block)42 ByteBuffer (java.nio.ByteBuffer)15 Test (org.junit.Test)11 BaseTest (org.apache.jena.atlas.junit.BaseTest)10 MappedByteBuffer (java.nio.MappedByteBuffer)2 TDBException (org.apache.jena.tdb.TDBException)2 Adler32 (java.util.zip.Adler32)1 BlockException (org.apache.jena.tdb.base.block.BlockException)1 BlockAccess (org.apache.jena.tdb.base.file.BlockAccess)1 ObjectFile (org.apache.jena.tdb.base.objectfile.ObjectFile)1 RecordBufferPage (org.apache.jena.tdb.base.recordbuffer.RecordBufferPage)1 FileRef (org.apache.jena.tdb.sys.FileRef)1