public void set(final long index, final byte[] bytes, final int start, final int length) { buffer.putBytes(index, bytes, start, length); }
private void loadPage(int index, Memory freePage) throws IOException { final long address = (long)index << PAGE_BITS; if (log.isDebugEnabled()) log.debug("loading page in file " + file.getPath() + " at address " + address); final int pageLength = (int)Math.min(PAGE_SIZE, length - address); synchronized (raf) { raf.seek(address); raf.readFully(pageBuffer, 0, pageLength); freePage.putBytes(0, pageBuffer, 0, pageLength); } }
@Override public void getBytes(long l, Memory dest, long start, long length) { checkBounds(l, length); dest.putBytes(start, data, (int)(offset+l), (int)length); }
@Override public void getBytes(long l, Memory dest, long start, long length) { if (dest.isDirect()) { getBytes(l, (DirectMemory) dest, start, length); } else { dest.putBytes(start, this, l, length); } }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (off < 0 || len < 0 || off+len > b.length) { throw new IndexOutOfBoundsException(); } try { memory.putBytes(currentAddress, b, off, len); currentAddress+=len; } catch (IndexOutOfBoundsException e) { toClose.add(buffer); buffer = new MMapBuffer(file, 0, memory.length() * 2, FileChannel.MapMode.READ_WRITE, byteOrder); memory = buffer.memory(); write(b, off, len); } }