Search in sources :

Example 21 with Block

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

the class BlockAccessDirect method read.

@Override
public Block read(long id) {
    check(id);
    checkIfClosed();
    ByteBuffer bb = ByteBuffer.allocate(blockSize);
    readByteBuffer(id, bb);
    bb.rewind();
    Block block = new Block(id, bb);
    return block;
}
Also used : Block(org.apache.jena.dboe.base.block.Block) ByteBuffer(java.nio.ByteBuffer)

Example 22 with Block

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

the class PageBlockMgr method promoteDuplicate.

/**
 * Promote a page - return 'true' if the block changed (.reset()) will have been called
 */
public boolean promoteDuplicate(Page page) {
    Block block = page.getBackingBlock();
    block.getByteBuffer().rewind();
    Block block2 = blockMgr.allocate(-1);
    block2.getByteBuffer().put(block.getByteBuffer());
    block2.getByteBuffer().rewind();
    block2.setReadOnly(false);
    if (block2 == block)
        return false;
    // Change - reset Block in page.
    page.reset(block2);
    return true;
}
Also used : Block(org.apache.jena.dboe.base.block.Block)

Example 23 with Block

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

the class PageBlockMgr method getRead$.

// ---- The read and write worker operations.
protected final T getRead$(int id) {
    Block block = blockMgr.getRead(id);
    // Blocks from the BlockMgrCache may be write-dirty so this test
    // is wrong in that situation.  It is better to use the block as-is
    // otherwise we'd have two blocks of a given id with different flags
    // that confuse the block caching.
    // if ( block.isModified() ) {
    // System.err.println("getRead - isModified - "+blockMgr.getLabel()+"["+id+"]");
    // //            block = new Block(block.getId(), block.getByteBuffer());
    // //            block.setModified(false);
    // // Debug.
    // //blockMgr.getRead(id);
    // }
    T page = pageFactory.fromBlock(block);
    return page;
}
Also used : Block(org.apache.jena.dboe.base.block.Block)

Example 24 with Block

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

the class BlockTracker method allocate.

@Override
public Block allocate(int blockSize) {
    Block block;
    synchronized (this) {
        checkUpdate(Alloc);
        block = blockMgr.allocate(blockSize);
        Long id = block.getId();
        activeWriteBlocks.add(id);
        add(Alloc, id);
    }
    return block;
}
Also used : Block(org.apache.jena.dboe.base.block.Block)

Aggregations

Block (org.apache.jena.dboe.base.block.Block)24 ByteBuffer (java.nio.ByteBuffer)7 Test (org.junit.Test)5 MappedByteBuffer (java.nio.MappedByteBuffer)2 InternalErrorException (org.apache.jena.atlas.lib.InternalErrorException)1