Search in sources :

Example 31 with Block

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

the class PageBlockMgr method free.

public void free(Page page) {
    Block block = page.getBackingBlock();
    blockMgr.free(block);
}
Also used : Block(org.apache.jena.tdb.base.block.Block)

Example 32 with Block

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

the class TestObjectFileBuffering method writePrealloc.

private void writePrealloc(int sizeOfBuffer, int... sizes) {
    ObjectFile file = make(sizeOfBuffer);
    int N = sizes.length;
    Block[] blocks = new Block[N];
    ByteBuffer[] read = new ByteBuffer[N];
    for (int i = 0; i < N; i++) {
        blocks[i] = file.allocWrite(sizes[i]);
        fill(blocks[i].getByteBuffer());
        file.completeWrite(blocks[i]);
    }
    for (int i = 0; i < N; i++) {
        read[i] = file.read(blocks[i].getId());
        assertNotSame(blocks[i].getByteBuffer(), read[i]);
        sameValue(blocks[i].getByteBuffer(), read[i]);
    }
}
Also used : ObjectFile(org.apache.jena.tdb.base.objectfile.ObjectFile) Block(org.apache.jena.tdb.base.block.Block) ByteBuffer(java.nio.ByteBuffer)

Example 33 with Block

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

the class AbstractTestBlockAccessVarSize method fileaccess_50.

@Test
public void fileaccess_50() {
    BlockAccess file = make();
    Block b1 = data(file, 10);
    Block b2 = data(file, 20);
    file.write(b1);
    file.write(b2);
    Block b1a = file.read(b1.getId());
    Block b2a = file.read(b2.getId());
    assertNotSame(b1a, b1);
    assertNotSame(b2a, b2);
    sameValue(b1, b1a);
    sameValue(b2, b2a);
}
Also used : BlockAccess(org.apache.jena.tdb.base.file.BlockAccess) Block(org.apache.jena.tdb.base.block.Block) Test(org.junit.Test)

Example 34 with Block

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

the class AbstractTestBlockAccessFixedSize method fileaccess_03.

@Test
public void fileaccess_03() {
    Block b1 = data(file, blkSize);
    file.write(b1);
    long x = b1.getId();
    Block b9 = file.read(x);
    assertNotSame(b1, b9);
    assertTrue(sameValue(b1, b9));
    b9 = file.read(x);
    assertNotSame(b1, b9);
    assertTrue(sameValue(b1, b9));
}
Also used : Block(org.apache.jena.tdb.base.block.Block) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 35 with Block

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

the class AbstractTestBlockAccessFixedSize method fileaccess_05.

@Test(expected = FileException.class)
public void fileaccess_05() {
    Block b1 = data(file, 10);
    Block b2 = data(file, 20);
    file.write(b1);
    // Should not work. b2 not written.   
    Block b2a = file.read(b2.getId());
}
Also used : Block(org.apache.jena.tdb.base.block.Block) 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