use of org.apache.jena.tdb.base.block.Block in project jena by apache.
the class BlockAccessMapped 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 id = allocateId();
ByteBuffer bb = getByteBuffer(id);
bb.position(0);
Block block = new Block(id, bb);
return block;
}
use of org.apache.jena.tdb.base.block.Block in project jena by apache.
the class BlockAccessMem 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 = blocks.size();
ByteBuffer bb = ByteBuffer.allocate(blkSize);
Block block = new Block(x, bb);
blocks.add(block);
return block;
}
use of org.apache.jena.tdb.base.block.Block in project jena by apache.
the class ObjectFileLogger method allocWrite.
@Override
public Block allocWrite(int maxBytes) {
Block blk = other.allocWrite(maxBytes);
info("allocWrite(" + maxBytes + ") -> " + blk.getId());
return blk;
}
use of org.apache.jena.tdb.base.block.Block in project jena by apache.
the class ObjectFileStorage method allocWrite.
@Override
public Block allocWrite(int bytesSpace) {
//log.info("AW("+bytesSpace+"):"+state()) ;
if (inAllocWrite)
Log.error(this, "In the middle of an alloc-write");
// Include space for length.
int spaceRequired = bytesSpace + SizeOfInt;
// Find space.
if (writeBuffer != null && spaceRequired > writeBuffer.remaining())
flushOutputBuffer();
if (writeBuffer == null || spaceRequired > writeBuffer.remaining()) {
// Too big. Have flushed buffering if buffering.
inAllocWrite = true;
ByteBuffer bb = ByteBuffer.allocate(bytesSpace);
allocBlock = new Block(filesize, bb);
allocLocation = -1;
//log.info("AW:"+state()+"-> ----") ;
return allocBlock;
}
// Will fit.
inAllocWrite = true;
int start = writeBuffer.position();
// Old values for restoration
oldBufferPosn = start;
oldBufferLimit = writeBuffer.limit();
// id (but don't tell the caller yet).
allocLocation = filesize + start;
// Slice it.
writeBuffer.putInt(bytesSpace);
writeBuffer.position(start + SizeOfInt);
writeBuffer.limit(start + spaceRequired);
ByteBuffer bb = writeBuffer.slice();
allocBlock = new Block(allocLocation, bb);
if (logging)
log("AW: %s->0x%X", state(), allocLocation);
return allocBlock;
}
use of org.apache.jena.tdb.base.block.Block in project jena by apache.
the class StringFile method write.
public long write(String str) {
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();
}
Aggregations