@Test public void testBufferSizing() { BlockByteBuffer bbb = new BlockByteBuffer(4, 100, 4, false); bbb.getByteBuffer(1); }
public ByteBuffer getByteBuffer(int block) { if (block < 0 || block >= data.blockCount) { throw new IndexOutOfBoundsException("Invalid block " + block); } int segment = block>>(data.segmentAddressBits-data.blockAddressBits); ByteBuffer bb = buffers[segment]; if (bb == null) { bb = buffers[segment] = data.origBuffers[segment].duplicate(data.direct); } else { bb.rewind(); } int position = (block<<data.blockAddressBits)&(data.segmentSize-1); bb.limit(position + data.blockSize); bb.position(position); return bb; }
BlockByteBuffer { public ByteBuffer getByteBuffer(int block) { if (block < 0 || block >= data.blockCount) { throw new IndexOutOfBoundsException("Invalid block " + block); } int segment = block>>(data.segmentAddressBits-data.blockAddressBits); ByteBuffer bb = buffers[segment]; if (bb == null) { bb = buffers[segment] = data.origBuffers[segment].duplicate(data.direct); } else { bb.rewind(); } int position = (block<<data.blockAddressBits)&(data.segmentSize-1); bb.limit(position + data.blockSize); bb.position(position); return bb; } }
BlockByteBuffer { public ByteBuffer getByteBuffer(int block) { if (block < 0 || block >= data.blockCount) { throw new IndexOutOfBoundsException("Invalid block " + block); } int segment = block>>(data.segmentAddressBits-data.blockAddressBits); ByteBuffer bb = buffers[segment]; if (bb == null) { bb = buffers[segment] = data.origBuffers[segment].duplicate(data.direct); } else { bb.rewind(); } int position = (block<<data.blockAddressBits)&(data.segmentSize-1); bb.limit(position + data.blockSize); bb.position(position); return bb; } BlockByteBuffer(int segmentAddressBits, int blockCount, int blockAddressBits, boolean direct); private  BlockByteBuffer(); }
BlockByteBuffer { public ByteBuffer getByteBuffer(int block) { if (block < 0 || block >= data.blockCount) { throw new IndexOutOfBoundsException("Invalid block " + block); } int segment = block>>(data.segmentAddressBits-data.blockAddressBits); ByteBuffer bb = buffers[segment]; if (bb == null) { bb = buffers[segment] = data.origBuffers[segment].duplicate(data.direct); } else { bb.rewind(); } int position = (block<<data.blockAddressBits)&(data.segmentSize-1); bb.limit(position + data.blockSize); bb.position(position); return bb; } BlockByteBuffer(int segmentAddressBits, int blockCount, int blockAddressBits, boolean direct); private  BlockByteBuffer(); ByteBuffer[] getBuffers(); static ByteBuffer allocate(int size, boolean direct); BlockByteBuffer duplicate(); ByteBuffer getByteBuffer(int block); }
BlockByteBuffer { public ByteBuffer getByteBuffer(int block) { if (block < 0 || block >= data.blockCount) { throw new IndexOutOfBoundsException("Invalid block " + block); } int segment = block>>(data.segmentAddressBits-data.blockAddressBits); ByteBuffer bb = buffers[segment]; if (bb == null) { bb = buffers[segment] = data.origBuffers[segment].duplicate(data.direct); } else { bb.rewind(); } int position = (block<<data.blockAddressBits)&(data.segmentSize-1); bb.limit(position + data.blockSize); bb.position(position); return bb; } BlockByteBuffer(int segmentAddressBits, int blockCount, int blockAddressBits, boolean direct); private  BlockByteBuffer(); ByteBuffer[] getBuffers(); static ByteBuffer allocate(int size, boolean direct); BlockByteBuffer duplicate(); ByteBuffer getByteBuffer(int block);  }