protected ByteBuffer sliceAsByteBuffer(ByteBuffer toReuse, Object att) { return ByteBufferReuse.INSTANCE.reuse(positionAddr, (int) remaining(), att, toReuse); }
protected ByteBuffer sliceAsByteBuffer(ByteBuffer toReuse, Object att) { return ByteBufferReuse.INSTANCE.reuse(positionAddr, (int) remaining(), att, toReuse); }
@Override public void write(RandomDataInput bytes, long position, long length) { if (length > remaining()) throw new IllegalArgumentException("Attempt to write " + length + " bytes with " + remaining() + " remaining"); if (bytes instanceof NativeBytes) { UNSAFE.copyMemory(((NativeBytes) bytes).startAddr + position, positionAddr, length); skip(length); } else { super.write(bytes, position, length); } }
@Override public int read(@NotNull byte[] bytes, int off, int len) { if (len < 0 || off < 0 || off + len > bytes.length) throw new IllegalArgumentException(); long left = remaining(); if (left <= 0) return -1; int len2 = (int) Math.min(len, left); UNSAFE.copyMemory(null, positionAddr, bytes, BYTES_OFFSET + off, len2); addPosition(len2); return len2; }
@Override public void write(RandomDataInput bytes, long position, long length) { if (length > remaining()) throw new IllegalArgumentException("Attempt to write " + length + " bytes with " + remaining() + " remaining"); if (bytes instanceof NativeBytes) { UNSAFE.copyMemory(((NativeBytes) bytes).startAddr + position, positionAddr, length); skip(length); } else { super.write(bytes, position, length); } }
@Override public int read(@NotNull byte[] bytes, int off, int len) { if (len < 0 || off < 0 || off + len > bytes.length) throw new IllegalArgumentException(); long left = remaining(); if (left <= 0) return -1; int len2 = (int) Math.min(len, left); UNSAFE.copyMemory(null, positionAddr, bytes, BYTES_OFFSET + off, len2); addPosition(len2); return len2; }
@Override public void write(byte[] bytes, int off, int len) { if (off < 0 || off + len > bytes.length || len > remaining()) throw new IllegalArgumentException(); UNSAFE.copyMemory(bytes, BYTES_OFFSET + off, null, positionAddr, len); addPosition(len); }
@Override public void write(byte[] bytes, int off, int len) { if (off < 0 || off + len > bytes.length || len > remaining()) throw new IllegalArgumentException(); UNSAFE.copyMemory(bytes, BYTES_OFFSET + off, null, positionAddr, len); addPosition(len); }
@Override public void readFully(@NotNull byte[] b, int off, int len) { checkArrayOffs(b.length, off, len); long left = remaining(); if (left < len) throw new IllegalStateException(new EOFException()); UNSAFE.copyMemory(null, positionAddr, b, BYTES_OFFSET + off, len); addPosition(len); }
@Override public void readFully(@NotNull byte[] b, int off, int len) { checkArrayOffs(b.length, off, len); long left = remaining(); if (left < len) throw new IllegalStateException(new EOFException()); UNSAFE.copyMemory(null, positionAddr, b, BYTES_OFFSET + off, len); addPosition(len); }
@Override public void readFully(@NotNull char[] data, int off, int len) { checkArrayOffs(data.length, off, len); long bytesOff = off * 2L; long bytesLen = len * 2L; long left = remaining(); if (left < bytesLen) throw new IllegalStateException(new EOFException()); UNSAFE.copyMemory(null, positionAddr, data, BYTES_OFFSET + bytesOff, bytesLen); addPosition(bytesLen); }
@Override public void readFully(@NotNull char[] data, int off, int len) { checkArrayOffs(data.length, off, len); long bytesOff = off * 2L; long bytesLen = len * 2L; long left = remaining(); if (left < bytesLen) throw new IllegalStateException(new EOFException()); UNSAFE.copyMemory(null, positionAddr, data, BYTES_OFFSET + bytesOff, bytesLen); addPosition(bytesLen); }
public void readUTF0(@NotNull Appendable appendable, int utflen) throws IOException { if (utflen > remaining()) throw new BufferUnderflowException(); if (appendable instanceof StringBuilder) readUTF1((StringBuilder) appendable, utflen); else readUTF1(appendable, utflen); }
public void readUTF0(@NotNull Appendable appendable, int utflen) throws IOException { if (utflen > remaining()) throw new BufferUnderflowException(); if (appendable instanceof StringBuilder) readUTF1((StringBuilder) appendable, utflen); else readUTF1(appendable, utflen); }