use of org.apache.jena.dboe.base.block.Block in project jena by apache.
the class BlockAccessDirect method allocate.
@Override
public Block allocate(int blkSize) {
if (blkSize > 0 && blkSize != this.blockSize)
throw new FileException("Fixed blocksize only: request= " + blkSize + "fixed size=" + this.blockSize);
int x = allocateId();
ByteBuffer bb = ByteBuffer.allocate(blkSize);
Block block = new Block(x, bb);
return block;
}
use of org.apache.jena.dboe.base.block.Block in project jena by apache.
the class BlockAccessMem method allocate.
@Override
public Block allocate(int blkSize) {
checkNotClosed();
if (blkSize > 0 && blkSize != this.blockSize)
throw new FileException("Fixed blocksize only: request= " + blkSize + " / fixed size=" + this.blockSize);
int x = blocks.size();
ByteBuffer bb = ByteBuffer.allocate(blkSize);
Block block = new Block(x, bb);
blocks.add(block);
return block;
}
use of org.apache.jena.dboe.base.block.Block in project jena by apache.
the class BPTreeNode method promote.
@Override
final boolean promote() {
if (bpTree.getNodeManager().isWritable(this.getId()))
return false;
// This calls reset is needed.
// The id, records buffer and pointer buffers need resetting if the block changed.
boolean promoteInPlace = bpTree.state().modifiableNodeBlock(getId());
if (promoteInPlace) {
bpTree.getNodeManager().promoteInPlace(this);
return false;
} else {
Block oldBlock = block;
boolean b = bpTree.getNodeManager().promoteDuplicate(this);
if (b) {
bpTree.getNodeManager().getBlockMgr().release(oldBlock);
}
return b;
}
}
use of org.apache.jena.dboe.base.block.Block in project jena by apache.
the class BPTreeRecords method promote.
@Override
final boolean promote() {
if (bprRecordsMgr.isWritable(getId()))
return false;
// reset() will be called if necessary.
boolean promoteInPlace = (bpTree == null) ? true : bpTree.state().modifiableRecordsBlock(getId());
if (promoteInPlace) {
bprRecordsMgr.promoteInPlace(this);
if (getBackingBlock().isReadOnly())
bprRecordsMgr.getBlockMgr().promote(getBackingBlock());
return false;
} else {
Block oldBlock = getBackingBlock();
boolean b = bprRecordsMgr.promoteDuplicate(this);
if (b)
bprRecordsMgr.getBlockMgr().release(oldBlock);
return b;
}
}
use of org.apache.jena.dboe.base.block.Block in project jena by apache.
the class BlockAccessByteArray method read.
@Override
public Block read(long id) {
// Variable length blocks.
if (id < 0 || id >= length || id >= bytes.capacity())
throw new FileException("Bad id (read): " + id);
bytes.position((int) id);
int len = bytes.getInt();
ByteBuffer bb = ByteBuffer.allocate(len);
// Copy out the bytes - copy for safety.
bytes.get(bb.array(), 0, len);
return new Block(id, bb);
}
Aggregations