@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); getChronicleUnsafe().copyMemory(null, position, bytes, BYTES_OFFSET + off, len2); addPosition(len2); return len2; }
@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); getChronicleUnsafe().copyMemory(null, position, bytes, BYTES_OFFSET + off, len2); addPosition(len2); return len2; }
@Override public long readVolatileLong() { long l = getChronicleUnsafe().getLongVolatile(null, position); addPosition(8); return l; }
@Override public double readDouble() { double d = getChronicleUnsafe().getDouble(position); addPosition(8); return d; }
@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()); getChronicleUnsafe().copyMemory(null, position, b, BYTES_OFFSET + off, len); addPosition(len); }
@Override public short readShort() { short s = getChronicleUnsafe().getShort(position); addPosition(2); return s; }
@Override public void write(long offset, @NotNull byte[] bytes) { if (offset < 0 || offset + bytes.length > capacity()) throw new IllegalArgumentException(); getChronicleUnsafe().copyMemory(bytes, BYTES_OFFSET, null, start + offset, bytes.length); addPosition(bytes.length); }
@Override public long readLong() { long l = getChronicleUnsafe().getLong(position); addPosition(8); return l; }
@Override public double readDouble() { double d = getChronicleUnsafe().getDouble(position); addPosition(8); return d; }
@Override public int readInt() { int i = getChronicleUnsafe().getInt(position); addPosition(4); return i; }
@Override public int readInt() { int i = getChronicleUnsafe().getInt(position); addPosition(4); return i; }
@Override public float readFloat() { float f = getChronicleUnsafe().getFloat(position); addPosition(4); return f; }
@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()); getChronicleUnsafe().copyMemory(null, position, data, BYTES_OFFSET + bytesOff, bytesLen); addPosition(bytesLen); }
@Override public float readFloat() { float f = getChronicleUnsafe().getFloat(position); addPosition(4); return f; }
@Override public void write(long offset, @NotNull byte[] bytes) { if (offset < 0 || offset + bytes.length > capacity()) throw new IllegalArgumentException(); getChronicleUnsafe().copyMemory(bytes, BYTES_OFFSET, null, start + offset, bytes.length); addPosition(bytes.length); }
@Override public byte readByte() { byte aByte = getChronicleUnsafe().getByte(position); addPosition(1); return aByte; }
@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()); getChronicleUnsafe().copyMemory(null, position, data, BYTES_OFFSET + bytesOff, bytesLen); addPosition(bytesLen); }
@Override public char readChar() { char ch = getChronicleUnsafe().getChar(position); addPosition(2); return ch; }
@Override public int readVolatileInt() { int i = getChronicleUnsafe().getIntVolatile(null, position); addPosition(4); return i; }
@Override public void write(byte[] bytes, int off, int len) { if (off < 0 || off + len > bytes.length || len > remaining()) throw new IllegalArgumentException(); getChronicleUnsafe().copyMemory(bytes, BYTES_OFFSET + off, null, position, len); addPosition(len); }