use of org.apache.jena.tdb.base.block.Block in project jena by apache.
the class ObjectFileTrans method allocWrite.
@Override
public Block allocWrite(int maxBytes) {
if (passthrough)
return base.allocWrite(maxBytes);
Block block = transObjects.allocWrite(maxBytes);
block = new Block(block.getId() + otherAllocOffset, block.getByteBuffer());
return block;
}
use of org.apache.jena.tdb.base.block.Block in project jena by apache.
the class NodeLib method encodeStore.
public static long encodeStore(Node node, ObjectFile file) {
// Buffer pool?
// Nodes can be writtern during reads.
// Make sure this operation is sync'ed.
int maxSize = nodec.maxSize(node);
Block block = file.allocWrite(maxSize);
try {
int len = nodec.encode(node, block.getByteBuffer(), null);
file.completeWrite(block);
return block.getId();
} catch (TDBException ex) {
file.abortWrite(block);
throw ex;
}
}
use of org.apache.jena.tdb.base.block.Block in project jena by apache.
the class AbstractTestObjectFile method objectfile_02.
@Test
public void objectfile_02() {
Block block = file.allocWrite(10);
fill(block.getByteBuffer());
file.completeWrite(block);
long x1 = block.getId();
assertEquals(0, x1);
ByteBuffer bb = file.read(x1);
// position
assertTrue(sameValue(block.getByteBuffer(), bb));
}
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;
}
Aggregations