@Override public void putBytes(long l, ByteBuffer source) { final int length = source.remaining(); checkBounds(l, length); if (source.isDirect()) { NativeMemoryUtils.copyFromDirectBuffer(source, source.position(), address+l, length); source.position(source.position()+length); } else if (source.hasArray()) { final byte[] array = source.array(); final int offset = source.arrayOffset(); putBytes(l, array, offset+source.position(), length); source.position(source.position()+length); } else { final byte[] copyBuffer = new byte[Math.min(length, 4096)]; long destAddr = l; while (source.remaining() > 0) { final int copySize = Math.min(copyBuffer.length, source.remaining()); source.get(copyBuffer, 0, copySize); putBytes(destAddr, copyBuffer, 0, copySize); destAddr+=copySize; } } }