@Override public Block allocWrite(int maxBytes) { return other.allocWrite(maxBytes) ; }
@Override public Block allocWrite(int maxBytes) { checkWriteTxn(); return objFile.allocWrite(maxBytes) ; }
@Override public Block allocWrite(int maxBytes) { Block blk = other.allocWrite(maxBytes) ; info("allocWrite("+maxBytes+") -> "+blk.getId()) ; return blk ; }
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() ; }
@Test public void objectfile_04() { Block block1 = file.allocWrite(10) ; fill(block1.getByteBuffer()) ; file.completeWrite(block1) ; Block block2 = file.allocWrite(20) ; fill(block2.getByteBuffer()) ; file.completeWrite(block2) ; long x1 = block1.getId() ; long x2 = block2.getId() ; assertFalse(x1 == x2) ; }
@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)) ; }
private void writePrealloc(int sizeOfBuffer, int... sizes) { ObjectFile file = make(sizeOfBuffer) ; int N = sizes.length ; Block blocks[] = new Block[N] ; ByteBuffer read[] = new ByteBuffer[N] ; for ( int i = 0 ; i < N ; i++ ) { blocks[i] = file.allocWrite(sizes[i]) ; fill(blocks[i].getByteBuffer()) ; file.completeWrite(blocks[i]) ; } for ( int i = 0 ; i < N ; i++ ) { read[i] = file.read(blocks[i].getId()) ; assertNotSame(blocks[i].getByteBuffer(), read[i]) ; sameValue(blocks[i].getByteBuffer(), read[i]) ; } }