use of org.apache.jena.tdb.base.block.Block in project jena by apache.
the class AbstractTestBlockMgr method file02.
@Test
public void file02() {
Block block = blockMgr.allocate(BlkSize);
ByteBuffer bb = block.getByteBuffer();
fill(bb, (byte) 1);
long id = block.getId();
blockMgr.write(block);
blockMgr.release(block);
Block block2 = blockMgr.getRead(id);
ByteBuffer bb2 = block2.getByteBuffer();
assertEquals(bb2.capacity(), BlkSize);
assertEquals(bb2.get(0), (byte) 1);
assertEquals(bb2.get(BlkSize - 1), (byte) 1);
blockMgr.release(block2);
}
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 DumpOps method dumpBlockMgr.
public static void dumpBlockMgr(PrintStream out, BlockMgr blkMgr) {
try {
for (int id = 0; id < 9999999; id++) {
if (!blkMgr.valid(id))
break;
Block blk = blkMgr.getRead(id);
out.print("id=" + blk.getId() + " ");
ByteBufferLib.print(out, blk.getByteBuffer());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
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 AbstractTestBlockAccessFixedSize method fileaccess_04.
@Test
public void fileaccess_04() {
Block b1 = data(file, blkSize);
Block b2 = data(file, blkSize);
file.write(b1);
file.write(b2);
long x = b1.getId();
Block b8 = file.read(b1.getId());
Block b9 = file.read(b1.getId());
assertNotSame(b8, b9);
assertTrue(b8.getId() == b9.getId());
}
Aggregations